-
OS: Windows 10 Pro - 21H2
-
Nodejs - v18.15.0
-
Composer version 2.5.5 2023-03-21 11:50:05
-
Xampp version 8.0.25
-
PHP 8.0.25 (cli) (built: Oct 25 2022 10:49:29) ( ZTS Visual C++ 2019 x64 )
-
Laravel Installer 4.5.0
-
Mysql Ver 15.1 Distrib 10.4.27-MariaDB, for Win64 (AMD64),
-
Download Laravel Installer using Composer
composer global require laravel/installer
-
Create project
composer create-project --prefer-dist laravel/laravel <project_name> # or cd <project_dir> laravel new <project_name> php artisan storage:link php artisan migrate php artisan migrate:fresh --seed php artisan migrate:refresh --seed
-
Once u're in Laravel proj, fire up the Laravel Dev Server to make app run by:
composer update composer install composer install --ignore-platform-reqs php artisan key:generate npm install npm run dev # Migrate database for system php artisan migrate --seed # Run seeder to create default for system php artisan db:seed --class=ContactSeeder php artisan db:seed
php artisan serve php artisan serve --port=8000 php artisan serve --port=8000 --host=0.0.0.0
-
-
Install Composer Dependencies
composer install
-
Install NPM Dependencies
npm install
-
Generate JS, CSS, image for system
npm run dev
-
Create a copy of your .env file
cp .env.example .env
-
Generate an app encryption key
php artisan key:generate
-
In the .env file, add database information to allow Laravel to connect to the database
In the .env file fill in the
DB_HOST
,DB_PORT
,DB_DATABASE
,DB_USERNAME
, andDB_PASSWORD
options to match the credentials of the database you just created. This will allow us to run migrations and seed the database in the next step. -
Migrate the database
php artisan migrate
-
Seed the database
php artisan db:seed
-
Recompile blade template
php artisan view:cache
-
-
Laravel project structure
-
app
dir: place the business logic of app, Laravel followMVC
pattern -> M, and C part are placed in this dir. -
config
dir: put the configuration of app. -
database
dir: some files working with DB, e.g: defining table schema, defining fake data. -
lang
dir: language files for inernationalization. -
public
dir: stores files that can be accessed publicly, you can put you images,CSS
andJS
files inside. -
resources
dir: contains views or files used to build app interface. -> V part ofMVC
is stores in views folder. this dir cũng chứa code JS, CSS đã compiled mà KHÔNG truy cập trực tiếp từ browser -
roots
dir: contains all the root definition for app -
storage
dir: contains logs, compile blade templates, file based session, file caches, and other file gen by framwork. -
test
dir: contains files for automated test. -
vendor
dir: all dependencies installed by the composer. -
.env
file: contains configs for env
-
-
Tinker
php artisan tinker
-
List all of the roots that are defined by app
php artisan route:list php artisan route:list --except-vendor php artisan route:list --only-vendor php artisan route:list --path=contacts php artisan route:list --path=contacts -
-
CREATE DATABASE
- create a new SQL databaseCREATE DATABASE contact_app;
-
SHOW DATABASE
- list all exist databaseSHOW DATABASE;
-
DESCRIBE
- show table's informationDESCRIBE migrations
-
ALTER DATABASE
- change the characteristics of a databaseALTER DATABASE database_name [COLLATE collation_name]
-
USE
- select a database to work withUSE contact_app;
-
CREATE TABLE
- create a new table in the databaseCREATE TABLE table_name ( column_1 datatype, column_2 datatype, column_3 datatype );
-
SHOW TABLES
- list all exist tables in databaseSHOW TABLES;
-
ALTER TABLE
- add, delete, or modify columns in an existing table.ALTER TABLE table_name ADD column_name datatype;
-
DROP TABLE
- delete an existing table in a databaseDROP TABLE table_name;
-
SELECT
- fetch data from a databaseSELECT column_name FROM table_name;
-
UPDATE
- edit rows in a tableUPDATE table_name SET some_column = some_value WHERE some_column = some_value;
-
DELETE
- remove rows from a tableDELETE FROM table_name WHERE some_column = some_value;
-
INSERT INTO
- add a new row to a tableINSERT INTO table_name (column_1, column_2, column_3) VALUES (value_1, ‘value_2’, value_3);
-
CREATE INDEX
- create an indexCREATE INDEX index_name ON table_name (column_name1, column_name2…);
-
DROP INDEX
- delete an indexALTER TABLE table_name DROP INDEX index_name;
- Get credentials
Email Testing > Inboxes > (select a Inbox) > SMTP Setting > Integrations (Laravel 7+) > Copy
- Config project
MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
routes\web.php
: define routes.resources\views
: V part in MVC pattern.