-
Clone this repository.
-
Install the dependencies. Run
composer install
command, then runnpm install
command. -
Create
.env
file by simply copying the.env.example
file and rename it. -
Configure the
.env
file with your database connection, seeder configuration, mailer, etc. -
Generate the application key with
php artisan key:generate
command. -
Generate the database structure with this commands based on your preferences:
- Use
php artisan migrate
for creating / updating the database. - Use
php artisan db:seed
for seeding the database. - Use
php artisan migrate:fresh
for fresh installation. - Use
php artisan migrate:fresh --seed
for fresh installation and seeding the database.
Warning! If you use
php artisan migrate:fresh
command, all tables will be dropped and recreated. All data in the tables will be lost. - Use
-
Generate the app resources (public assets, like: styles, scripts, etc.)
- In development, use
npm run dev
command. - In production, use
npm run prod
command.
Note: Before running in watch mode, you need to start the application first.
- In development, use
-
Finally, start the application with
php artisan serve
command.
Laravel Sail is used to help dockerize this app easily. Laravel Sail is supported on:
- macOS
- Linux
- Windows (via WSL2)
To install this application with Docker, you must have Docker running on your machine.
Please go to the Docker installation guide, select your platform machine, and follow the instructions.
The docker-compose.yml file is used to define the app's services, consist of:
laravel.test
- the app container, which is based on Laravel Sail's PHP 8.2 image.mysql
- the database container, which is based on MySQL Server 8.0 image.
-
Clone this repository.
-
Install the dependencies.
Move to the application's directory, then execute the following command:
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
This command will installing the back-end dependencies.
See the Installing Composer Dependencies for Existing Projects in Laravel documentation for details.
-
Create
.env
file and configure it -
Build and start the app
Run this command:
./vendor/bin/sail up -d
This command will download and install the container images that defined in docker-compose.yml if not exists, then start the app container (include the database container).
To stop the app, use
./vendor/bin/sail down
command. -
Accessing the app container from Bash
After the containers run, you can access the app container from the Bash CLI using this command:
./vendor/bin/sail bash
Then you can execute any command directly inside the container, like
npm run dev
.See Executing Commands in Laravel documentation for details.
-
Install the front-end dependencies
To install the front-end dependencies, you can use
./vendor/bin/sail npm install
command to execute it from app directory.If you have already in the app container (previous step), you can run
npm install
directly.See Executing Node / NPM Commands in Laravel documentation.
-
Generate the app key
-
Generate the database
-
Generate the app resources
-
Last, open the app
Open your browser and go to
http://localhost:8000
(orhttp://localhost:APP_PORT
if you have changed theAPP_PORT
in.env
file).