The last years I was using devilbox a lot.
It has quite a simple setup for CakePHP apps, that are not using too many different external services.
Over the years that got less maintained. I started to also look into other options.
I saw several docker based systems to become more popular. Maybe I will have the chance to dive more into those, too, one day.
Traefik seems to be a powerful tool if you need more customized systems.
I want to present a less dev-op and more dev-friendly tool that uses it internally.
ddev
ddev is the new easy to setup local dev.
One of the really cool things about this modern tool is that can recognize different framework types and support them out of the box.
Setup
Once you installed ddev, just create your fresh cakephp/app
clone via composer create-project
or manually and run the ddev config
command.
CakePHP apps should be autodetected, and webroot should be the public folder detected.
Just create your app_local.php
from the example file and you are all set to go.
ddev start
Use this command to log into the container:
ddev ssh
Here you can also execute composer or migrations:
composer install
bin/cake migrations status|migrate|...
Usage
ddev launch
This should open the browser and you should see the default home screen of your (fresh) app.
All should be working right away.
It will probably open your browser and jump to your homepage. In case the app name is app
, the URL would be
http://app.ddev.site/
It doesn’t need to modify your /etc/hosts
file even. It just works out of the box.
If you want to see your local configs, use
ddev describe
Useful shortcuts
If you just want to run some bin/cake command, you can also use the shortcut method from the outside without the need to ssh into the container:
ddev cake [command]
Without [command] you just the same overview as always.
Addons
Some people prefer Mysql workbench or alike to connect to the DB. I personally like
phpmyadmin as it is super simple to also inline-edit.
After the installation, calling
ddev phpmyadmin
directly opens the browser with in my case
https://app.ddev.site:8037/
showing the PHPMyAdmin dashboard and your initial DB.
There are quite a bunch of other addons available, too.
Xdebug
The powerful tool to easily debug your code at runtime is also enabled and used relatively easy, I noticed.
ddev xdebug
enables Xdebug.
Then activate the browser IDE key
with e.g. PHPSTORM
for PHPStorm IDE. Add the server config on the IDE site to map the external path to the internal (/var/www/html
) and then
start listening.
Once you set a breakpoint and reload the page, it should jump right into the IDE here.
Stepping through is vital to find out why in certain cases it jumps into a different path than expected. Using dd()
here can be cumbersome as you might need several tries to find the path it took, and
to see the values it has on each decision point.
See docs for details.