This project is a PHP application built using the Laravel framework. It utilizes Docker containers to manage the development environment and ensure consistency across different systems. The project is designed to be portable and easy to set up.
The project is structured as follows:
docker
: Docker infrastructure files.src
: The main source code directory containing the application's PHP files..env*
files: Contain environment variables used by the Docker containers.compose*.yml
: The Docker Compose file that defines the services and their configurations.Makefile
: The Docker Compose CLI entry point.
You must have installed on your system:
-
Docker, native or OrbStack. On MacOS it is preferable to install OrbStack:
brew install --cask orbstack
-
make
brew install make
To get started with the project, follow these steps:
- Clone the repository to your local machine.
- Navigate to the project directory in your terminal.
- Run
make init
ormake init-dev
to initialize Docker infrastructure. - Edit
.env
file and setPROJECT_NAME
to your desired project name (my-app
). - Run
make build
to pull and build Docker images. - Run
make up
to start the Docker containers.
If it is fresh installation, prepare new Laravel application:
-
Run
make shell
to get bash inside PHP container. -
Run
composer global require laravel/installer
to install Laravel installer. -
Create new Laravel application and follow installer prompts. At this point the database is ready and migrations can be executed.
laravel new my-app --stack=livewire --jet --api --teams --verification --pest --force --database=mariadb
-
Move files from
my-app
directory to the project source root and removemy-app
directory:mv my-app/* . mv my-app/.* . rm -rf my-app/
-
Update
src/vite.config.js
, addserver
section for proper hot module reload support:export default defineConfig(({ command }) => { const config = { plugins: [ laravel({ input: [ 'resources/css/app.css', 'resources/js/app.js', ], refresh: true, }), ], server: { host: true, } }; if (command !== 'build') { config.server.hmr = { host: "my-app.docker.localhost" }; } return config; });
-
Restart node container
make restart node
and open your browser at https://my-app.docker.localhost/.
- Run
make shell
to get bash inside PHP container.
Logs are written to files under src/storage/logs
.