examples/stacks/laravel/README.md
Laravel is a powerful web application framework built with PHP. It's a great choice for building web applications and APIs.
This example shows how to build a simple Laravel application backed by MariaDB and Redis. It uses Devbox Plugins for all 3 Nix packages to simplify configuration
Install Devbox
Create a new Laravel App by running devbox create --template laravel. This will create a new Laravel project in your current directory.
Start your MariaDB and Redis services by running devbox services up.
Create the laravel database by running devbox run db:create, and then run Laravel's initial migrations using devbox run db:migrate
You can now start the artisan server by running devbox run serve:dev. This will start the server on port 8000, which you can access at localhost:8000
If you're using Laravel on Devbox Cloud, you can test the app by appending /port/8000 to your Devbox Cloud URL
For more details on building and developing your Laravel project, visit the Laravel Docs
Create a new project with devbox init
Add the packages using the command below. Installing the packages with devbox add will ensure that the plugins are activated:
devbox add mariadb@latest, [email protected], nodejs@18, redis@latest, php81Packages.composer@latest
Run devbox shell to start your shell. This will also initialize your database by running initdb in the init hook.
Create your laravel project by running:
composer create-project laravel/laravel tmp
mv tmp/* tmp/.* .
To use MariaDB, you need to create the default Laravel database. You can do this by running the following commands in your devbox shell:
# Start the MariaDB service
devbox services up mariadb -b
# Create the database
mysql -u root -e "CREATE DATABASE laravel;"
# Once you're done, stop the MariaDB service
devbox services stop mariadb