In the realm of web development, a seamless local environment is the bedrock for efficient and stress-free coding. Enter DDEV, a powerful tool that simplifies the setup process and empowers developers to dive into their projects with ease.
In this blog post, we'll embark on a journey to demystify the process of setting up a local development environment using DDEV. Whether you're a seasoned developer or just starting in the world of web development, optimizing your local environment can significantly enhance your workflow.
Pre Conditions :
Step 1: Create a new CakePHP project skeleton
composer create-project cakephp/app myproject
A new folder "myproject" will be created with a CakePHP project skeleton inside. Go to this new directory and proceed with the following instructions.
Step 2: Initial ddev setup
This will do the initial ddev setup, press enter for all questions.
ddev auth ssh
This will add ssh key authentication to the ddev-ssh-auth container
Step 3: Adjust the settings
Inside "myproject" a new .ddev folder will be created, open config.yaml and adjust there: php version, database and the database url environment.
For the database:
database: type: mysql version: "8.0"
For the environment variable:
web_environment: - DATABASE_URL=mysql://db:db@db/db
Step 4: Start ddev
This will spin up the project.
Step 5: Open your application
This will open your project in a browser.
Once you have the application up and running, some useful commands you could run are:
ddev composerto execure composer
ddev mysqlto get into the database
ddev sshtakes you into the web container.
In this link https://ddev.readthedocs.io/en/latest/users/usage/cli/ you can see more useful commands.
Hope you enjoy playing with DDEV!