shdpl / Laravel-Package-Docker-Development-Tools

Laravel Package Docker Development Tools Helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Laravel Package Docker Development Tools

This repo aims to help developers maintain external Laravel packages.

Includes folders

  • host default Laravel instance
  • docker config files
  • packages folder that includes each of packages

Launching

docker-compose up -d should be enough

By default Laravel is using mysql DB, but you can change this in host/.env file

CLI Commands. artisan & composer

Enter bash by calling docker-compose exec escola_lms_app bash, then lanuch any command like artisan or composer.

How to use this

Repeat those steps for each package

  1. Clone your package to a folder inside this repo, in packages folder (git clone XXX package). Add your folder to .gitignore

  2. Amend Host Laravel host/composer.json to point to freshly cloned package repository. Assuming your package name is escolalms/packagename, it can be done by invoking following command from within the container:

composer config repositories.escolalms/packagename '{ "type": "path", "url": "../packages/packagename" }'

2.1. (Optional) In case you'll be generating your own swagger documentation you might want to alter host/config/l5-swagger.php as follows:

Before:

'annotations' => [
               base_path('vendor/escolalms/headless-h5p/src'),
               //base_path('app')
],

After:

'annotations' => [
               base_path('vendor/escolalms/mypackage/src'),
               //base_path('app')
],

Above example is assuming that your package name is mypackage.

  1. Enter bash (instruction above), then add you packge with composer require escolalms/headless-h5p

That's it - now you have laravel working with docker that is using package from other folder that is git maintained.

Xdebug remote debbuging

Note instruction below is for VSCODE, yet it should work with minor changes in other IDEs like PHPStorm.

  1. Add mapping to .vscode/launch.json

Before:

    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/var/www/html": "${workspaceFolder}/host",
            }
        },

After:

    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/var/www/html": "${workspaceFolder}/host",
                "/var/www/package": "${workspaceFolder}/package"
            }
        },
  1. Enable Xdebug

Note instruction below is for VSCODE, nad Xdebug 3 (included in this Docker), port 9003 yet it should work with minor changes in other IDEs like PHPStorm. Our settings is based on DevilBox (Configure Xdebug).

  1. Uncomment all Xdebug settings from docker/xxx-devilbox-default-php.ini
  2. Add host address alias, eg on MacOS sudo ifconfig lo0 alias 10.254.254.254
  3. Restart docker with docker-compose stop escola_lms_app && docker-compose rm escola_lms_app && docker-compose up -d
  4. Install default Xdebug debugging tools
  5. Add at least one breakpoint to your package
  6. Select option Listen for Xdebug from IDE debugger
  7. Run your app with XDEBUG GET query param, example http://localhost:1000/api/hh5p/library?XDEBUG_SESSION_START=VSCODE
  8. Debugger should stop on breakpoint in IDE

About

Laravel Package Docker Development Tools Helper

License:Apache License 2.0


Languages

Language:PHP 85.2%Language:Blade 13.7%Language:HTML 1.0%Language:Makefile 0.0%