Make sure the following are installed on your system:
- PHP >= 8.0
- Composer
- MySQL (or any other supported database)
- Node.js & npm (optional, for frontend assets)
Install all PHP dependencies via Composer:
composer installIf the .env file is missing, copy it from the example:
cp .env.example .envLaravel uses MySQL by default. To use a different database, update config/database.php and your .env file.
- Install and configure your preferred database.
- Create a new database for the project.
- Update your
.envfile with the correct credentials:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_database_name DB_USERNAME=your_username DB_PASSWORD=your_password
php artisan key:generateRun database migrations to create all necessary tables:
php artisan migrateTo populate your database with sample data:
php artisan db:seedTo make uploaded files publicly accessible:
php artisan storage:linkphp artisan servePlace your project in the Valet directory and access it via http://project-name.test.
If your project uses Vite, Laravel Mix, or any frontend build system:
npm install && npm run devFor production:
npm run build-
Don’t forget to set the correct
APP_URLin your.env:APP_URL=http://localhost:8000
-
Clear caches if necessary:
php artisan config:clear php artisan cache:clear php artisan route:clear
Happy coding! 🧑💻
This project may include automated tests using Pestphp.
php artisan testOr directly via Pestphp:
./vendor/bin/pestTo avoid affecting development or production data, configure a separate database for testing by adding the following to your .env:
DB_DATABASE=your_testing_databaseThen, in phpunit.xml, set the appropriate environment:
<env name="DB_CONNECTION" value="mysql"/>
<env name="DB_DATABASE" value="your_testing_database"/>You can also refresh the test database before each test run with Laravel's RefreshDatabase trait.