Skip to content

Changing the code

This guide explains the standard way to make changes to the code of this package.

Prerequisites

To make changes to this package you first need to set up a small development application where you can test your changes.

Then follow the [installation] guide to install the package to your application.

Testing changes

Changes to PHP-Code are available immediately to your main project.

For making changes to your assets (Javascript, Vue, CSS) you must install the composer and npm dependencies for this package first:

# change to the packages folder
cd vendor/john-it-com/bc-ui-presentation/
# install the packages dependencies
composer install
npm install

Then you can make your changes. If you want to test your changes you need to recompile and republish your assets first before they are available for testing in your main project.

Therefor you need to run the following commands:

# change to the packages folder
cd vendor/john-it-com/bc-ui-presentation/
# re-compile your assets to src/dist/
npm run build
# change to your main projects root folder
cd ../../../
# re-publish your assets
php artisan vendor:publish --tag=public --force

Now changes to your assets should be available for testing in your main projects. Re-compiling and re-publishing your assets needs to be done after each change.

If you don’t want to recompile and re-publish your assets after every change you can temporary mount the folder vendor/john-it-com/bc-ui-presentation/src/Resources/dist as avolume to /var/www/html/public/vendor/john-it-com/bc-ui-presentation inside the php docker container. Therefore you need to add the following line to your docker-compose.yml:

services:
    php:
        volumes:
            - ./vendor/john-it-com/bc-ui-presentation/src/Resources/dist:/var/www/html/public/vendor/john-it-com/bc-ui-presentation

Afterwards it should look like this:

            # Mount the sources into the container so that it doesn't
            # have to be rebuilt and restarted just for changes to
            # take effect.
            - .:/var/www/html
            # Temporarily mount the packages dist folder to the public folder
            - ./vendor/john-it-com/bc-ui-presentation/src/Resources/dist:/var/www/html/public/vendor/john-it-com/bc-ui-presentation

Then rebuild your docker image by running bin/ptr build inside your projects folder and then run npm run watch inside the packages folder. Don’t forget to reload your browser without cache (STRG+F5).