These instructions will guide you through setting up the project on your local machine for development and testing.
You need to have installed the following software:
- PHP 8.2
- Composer 2.0.8
- MySQL 8.0.23
- Node 20.10.0
Follow these steps to set up a development environment:
-
Clone the repository
git clone https://github.com/mr-punyapal/basic-crud.git
-
Install dependencies
composer install
npm install
-
Duplicate the .env.example file and rename it to .env
cp .env.example .env
-
Generate the application key
php artisan key:generate
-
Run migration and seed
php artisan migrate --seed
-
Run the application
npm run dev
php artisan serve
-
Copy .env.testing.example to .env.testing
-
Update the database configuration according to your local environment
-
Create a new database for testing
-
Run the following commands
php artisan key:generate --env=testing
npm install && npm run build
./vendor/bin/pest --parallel
Laravel Sail is helpful when your local environment doesn't match with project requirements like different PHP versions. Only requirement is Docker to work with this project. For more details on Laravel Sail click here.
Follow these steps to set up a development environment using Laravel Sail:
-
Clone the repository
git clone https://github.com/mr-punyapal/basic-crud.git
-
Duplicate the .env.example file and rename it to .env
cp .env.example .env
Update the
DB_HOST
environment variable to valuemysql
(should be same as service name of database server) -
Install dependencies
docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php82-composer:latest \ composer install --ignore-platform-reqs
./vendor/bin/sail run --rm laravel.test npm install
-
Run the application
./vendor/bin/sail up -d
./vendor/bin/sail npm run dev
-
Generate the application key
./vendor/bin/sail artisan key:generate
-
Run migration and seed
./vendor/bin/sail artisan migrate --seed
-
Copy .env.testing.example to .env.testing
-
Update the
DB_HOST
environment variable to valuemysql
(should be same as service name of database server) -
Create a new database for testing
./vendor/bin/sail mysql > create database <testing_database_name>
-
Run the following commands
./vendor/bin/sail artisan key:generate --env=testing
./vendor/bin/sail npm install && ./vendor/bin/sail npm run build
./vendor/bin/sail run --rm laravel.test ./vendor/bin/pest --parallel
Give your feedback on @MrPunyapal
Contribute if you have any ideas to improve this project.