php artisan migrate:fresh --seed
\ \ \ \
\ \ \ `-- Call seeders.
\ \ `-- Drop all tables and run migrations.
\ `-- General command.
`-- ?
cd {SITE_DIRECTORY}
git pull origin main
# git fetch --all
# git reset --hard origin/main
{SITE_PHP} artisan down
{SITE_COMPOSER} install --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service {SITE_PHP}-fpm reload
{SITE_PHP} artisan optimize:clear
{SITE_PHP} artisan optimize
{SITE_PHP} artisan migrate --force
# {SITE_PHP} artisan migrate:fresh --seed --force
{SITE_PHP} artisan up
echo "🚀 Application deployed!"
host file location
C:\Windows\System32\Drivers\etc\hosts
php artisan make:migration create_articles-table --create=articles 创建表
php artisan make:migration add_inro_colum_to_articles --table=articles
php artisan make:model Article 创建一个 mode 继承 article
php artisan tinker
# Starts a development server at http://localhost:8000
php artisan serve
# Creates a new controller class
php artisan make:controller
# Creates a new Eloquent model class
php artisan make:model
# Creates a new migration file
php artisan make:migration
# Runs any pending migrations
php artisan migrate
# Rolls back the last batch of migrations
php artisan migrate:rollback
# Creates a new seeder class
php artisan make:seeder
# Runs the database seeder and seeds the database with sample data
php artisan db:seed
# Creates a new test case class
php artisan make:test
# Runs the application tests
php artisan test
# Creates a cache file for faster configuration loading
php artisan config:cache
# Clears the configuration cache
php artisan config:clear
# Displays a list of all registered routes
php artisan route:list
# Clears the application cache
php artisan cache:clear
# Clears all compiled view files
php artisan view:clear
# Generate a model and a FlightFactory class...
php artisan make:model Flight --factory
php artisan make:model Flight -f
# Generate a model and a FlightSeeder class...
php artisan make:model Flight --seed
php artisan make:model Flight -s
# Generate a model and a FlightController class...
php artisan make:model Flight --controller
php artisan make:model Flight -c
# Generate a model, FlightController resource class, and form request classes...
php artisan make:model Flight --controller --resource --requests
php artisan make:model Flight -crR
# Generate a model and a FlightPolicy class...
php artisan make:model Flight --policy
# Generate a model and a migration, factory, seeder, and controller...
php artisan make:model Flight -mfsc
# Shortcut to generate a model, migration, factory, seeder, policy, controller, and
form requests...
php artisan make:model Flight --all
# Generate a pivot model...
php artisan make:model Member --pivot
php artisan make:model Member -p
Declare all the files that would be included to include requests and combine them
in a single file
php artisan optimize --force
Composer scan the application and create a one-to-one association of the classes
and files in the application
composer dumpautoload -o
php artisan config:clear
php artisan config:cache
php artisan route:clear
php artisan route:cache
php artisan view:clear
php artisan view:cache
php artisan optimize:clear
$this->call('view:clear');
$this->call('cache:clear');
$this->call('route:clear');
$this->call('config:clear');
$this->call('clear-compiled');
php artisan optimize
$this->call('config:cache');
$this->call('route:cache');
// for migration
php artisan migrate
// for installing laravel passport package
php artisan passport:install
// for passport key
php artisan passport:keys
// Create data seeder seeder_name like TourTableDataSeeder
php artisan make:seeder <seeder_name>
// Run data seeder seeder_name like TourTableDataSeeder
php artisan db:seed --class=TourPackagesTableDataSeeder<seeder_name>
// create migration with models
php artisan make:model Models/Tours -m
// Data import from seeder
php artisan db:seed
// Key Generation
php artisan key:generate
// Server Start
php artisan serve
// To controller create
php artisan make:controller Api/TourController (edited)
[Generate a key]
php artisan key:generate
[Cache the configuration file (update the cache in bootstrap/cache/config.php)]
php artisan config:cache
[Cache the routing definition]
php artisan route:cache
[List the cached routing definition]
php artisan route:list
[Create a controller]
php artisan make:controller HelloController
[Create a form request app/Http/Requests/ContactRequest/]
php artisan make:request ContactRequest
php artisan make:seeder PeopleTableSeeder
php artisan db:seed
php artisan db:seed --class=PeopleTableSeeder
> "Class UsersSeeder does not exist"
The added class is not autoloaded.
If this happens, run dump-autoload to redefine the autoloaded class.
composer dump-autoload
##### Direct to project folder #########
sudo chown -R www-data:www-data /var/www/sump/
# Re-optimization of loader class:
php artisan optimize
# Clear cache
php artisan cache:clear
php artisan route:cache
php artisan view:clear
# Clear config cache:
php artisan config:clear
php artisan cache:clear
php artisan view:clear
composer dump-autoload
php artisan clear-compiled
php-timezone.php
<?php
$items = [];
array_push($items, ["key" => "Current Date T", "value" => date('Y-m-d H:i:s
T')]);
array_push($items, ["key" => "Current Date", "value" => $date = date('Y-m-d
H:i:s')]);
array_push($items, ["key" => "LOCALE TIMESTAMP: ", "value" =>
strtotime($date)]); // true
array_push($items, ["key" => "UTC TIMESTAMP: ", "value" => strtotime($date."
UTC")]); // wrong
array_push($items, ["key" => "TIME", "value" => time()]);
array_push($items, ["key" => "BD from LOCALE", "value" => strtotime("1992-01-28
02:00:00")]); // 696556800
array_push($items, ["key" => "BD from UTC 00:00:00", "value" =>
strtotime("1992-01-28 00:00:00 UTC")]); // 696556800
array_push($items, ["key" => "GMT Date", "value" => $gmtdate = gmdate("Y-m-d T
H:i:s", 1517832507)]);
array_push($items, ["key" => "Date", "value" => date('d-m-Y T H:i:s',
1517832507)]);
array_push($items, ["key" => "UTC TIME", "value" => strtotime($gmtdate."
UTC")]);
array_push($items, ["key" => "UTC TIME", "value" => strtotime($gmtdate)]);
echo "<table>";
foreach ($items as $item){
echo "<tr>";
echo "<td><strong>{$item['key']}</strong></td>";
echo "<td>{$item['value']}</td>";
echo "</tr>";
}
echo "</table>";
?>
1: Set up two-step authentication for your Google account.
2: Generate an app password
https://security.google.com/settings/security/apppasswords
3: Add to .env
4: Send a test email
php artisan tinker
>>> Mail::raw('test mail',function($message) {$message->to('to@mail.com')-
>subject('test');});
>>> Mail::send('email.contact', ['name' => 'meta','text'=>'test'],
function($message){ $message->to('to@email.com')->subject('test'); });
If an error occurs
php artisan cache:clear
php artisan config:cache
Debug information
dd(\Config::get('mail'));
Check RAM: free -h
Check SSD: df -h --total
Check CPU: lscpu
mklink /D Link Target
Use /D when you want to create a soft link pointing to a directory.
mklink /H Link Target
Use /H when you want to create a hard link pointing to a file
mklink /J Link Target
Use /J to create a hard link pointing to a directory, also known as a directory
junction
-------
dir /AL /S C:\
/A displays all files with a specific attribute, and L specifies reparse points
(symlinks and directory junctions)
/S makes the command recursive
replace C:\ with the drive letter you want to scan, or with a path if you don't
want to scan an entire drive
Linux
ln -s laravel/public public_html
NOTE: HARUS MASUK DI FOLDER TUJUAN DULU
Utility commands module:make Generate a new module.
php artisan module:make Blog module:make Generate multiple modules at once.
php artisan module:make Blog User Auth module:use Use a given module. This allows
you to not specify the module name on other commands requiring the module name as
an argument.
php artisan module:use Blog module:unuse This unsets the specified module that was
set with the module:use command.
php artisan module:unuse module:list List all available modules.
php artisan module:list module:migrate Migrate the given module, or without a
module an argument, migrate all modules.
php artisan module:migrate Blog module:migrate-rollback Rollback the given module,
or without an argument, rollback all modules.
php artisan module:migrate-rollback Blog module:migrate-refresh Refresh the
migration for the given module, or without a specified module refresh all modules
migrations.
php artisan module:migrate-refresh Blog module:migrate-reset Blog Reset the
migration for the given module, or without a specified module reset all modules
migrations.
php artisan module:migrate-reset Blog module:seed Seed the given module, or without
an argument, seed all modules
php artisan module:seed Blog module:publish-migration Publish the migration files
for the given module, or without an argument publish all modules migrations.
php artisan module:publish-migration Blog module:publish-config Publish the given
module configuration files, or without an argument publish all modules
configuration files.
php artisan module:publish-config Blog module:publish-translation Publish the
translation files for the given module, or without a specified module publish all
modules migrations.
php artisan module:publish-translation Blog module:enable Enable the given module.
php artisan module:enable Blog module:disable Disable the given module.
php artisan module:disable Blog module:update Update the given module.
php artisan module:update Blog Generator commands module:make-command Generate the
given console command for the specified module.
php artisan module:make-command CreatePostCommand Blog module:make-migration
Generate a migration for specified module.
php artisan module:make-migration create_posts_table Blog module:make-seed Generate
the given seed name for the specified module.
php artisan module:make-seed seed_fake_blog_posts Blog module:make-controller
Generate a controller for the specified module.
php artisan module:make-controller PostsController Blog module:make-model Generate
the given model for the specified module.
php artisan module:make-model Post Blog Optional options:
--fillable=field1,field2: set the fillable fields on the generated model --
migration, -m: create the migration file for the given model module:make-provider
Generate the given service provider name for the specified module.
php artisan module:make-provider BlogServiceProvider Blog module:make-middleware
Generate the given middleware name for the specified module.
php artisan module:make-middleware CanReadPostsMiddleware Blog module:make-mail
Generate the given mail class for the specified module.
php artisan module:make-mail SendWeeklyPostsEmail Blog module:make-notification
Generate the given notification class name for the specified module.
php artisan module:make-notification NotifyAdminOfNewComment Blog module:make-
listener Generate the given listener for the specified module. Optionally you can
specify which event class it should listen to. It also accepts a --queued flag
allowed queued event listeners.
php artisan module:make-listener NotifyUsersOfANewPost Blog php artisan
module:make-listener NotifyUsersOfANewPost Blog --event=PostWasCreated php artisan
module:make-listener NotifyUsersOfANewPost Blog --event=PostWasCreated --queued
module:make-request Generate the given request for the specified module.
php artisan module:make-request CreatePostRequest Blog module:make-event Generate
the given event for the specified module.
php artisan module:make-event BlogPostWasUpdated Blog module:make-job Generate the
given job for the specified module.
php artisan module:make-job JobName Blog
php artisan module:make-job JobName Blog --sync # A synchronous job class
module:route-provider Generate the given route service provider for the specified
module.
php artisan module:route-provider Blog module:make-factory Generate the given
database factory for the specified module.
php artisan module:make-factory FactoryName Blog module:make-policy Generate the
given policy class for the specified module.
The Policies is not generated by default when creating a new module. Change the
value of paths.generator.policies in modules.php to your desired location.
php artisan module:make-policy PolicyName Blog module:make-rule Generate the given
validation rule class for the specified module.
The Rules folder is not generated by default when creating a new module. Change the
value of paths.generator.rules in modules.php to your desired location.
php artisan module:make-rule ValidationRule Blog module:make-resource Generate the
given resource class for the specified module. It can have an optional --collection
argument to generate a resource collection.
The Transformers folder is not generated by default when creating a new module.
Change the value of paths.generator.resource in modules.php to your desired
location.
php artisan module:make-resource PostResource Blog php artisan module:make-resource
PostResource Blog --collection module:make-test Generate the given test class for
the specified module.
php artisan module:make-test EloquentPostRepositoryTest Blog
```php
$table->bigIncrements('id'); Auto-incrementing UNSIGNED BIGINT (primary key)
equivalent column.
$table->bigInteger('votes'); BIGINT equivalent column.
$table->binary('data'); BLOB equivalent column.
$table->boolean('confirmed'); BOOLEAN equivalent column.
$table->char('name', 100); CHAR equivalent column with an optional length.
$table->date('created_at'); DATE equivalent column.
$table->dateTime('created_at'); DATETIME equivalent column.
$table->dateTimeTz('created_at'); DATETIME (with timezone) equivalent column.
$table->decimal('amount', 8, 2); DECIMAL equivalent column with a precision (total
digits) and scale (decimal digits).
$table->double('amount', 8, 2); DOUBLE equivalent column with a precision (total
digits) and scale (decimal digits).
$table->enum('level', ['easy', 'hard']); ENUM equivalent column.
$table->float('amount', 8, 2); FLOAT equivalent column with a precision (total
digits) and scale (decimal digits).
$table->geometry('positions'); GEOMETRY equivalent column.
$table->geometryCollection('positions'); GEOMETRYCOLLECTION equivalent column.
$table->increments('id'); Auto-incrementing UNSIGNED INTEGER (primary key)
equivalent column.
$table->integer('votes'); INTEGER equivalent column.
$table->ipAddress('visitor'); IP address equivalent column.
$table->json('options'); JSON equivalent column.
$table->jsonb('options'); JSONB equivalent column.
$table->lineString('positions'); LINESTRING equivalent column.
$table->longText('description'); LONGTEXT equivalent column.
$table->macAddress('device'); MAC address equivalent column.
$table->mediumIncrements('id'); Auto-incrementing UNSIGNED MEDIUMINT (primary key)
equivalent column.
$table->mediumInteger('votes'); MEDIUMINT equivalent column.
$table->mediumText('description'); MEDIUMTEXT equivalent column.
$table->morphs('taggable'); Adds taggable_id UNSIGNED BIGINT and taggable_type
VARCHAR equivalent columns.
$table->multiLineString('positions'); MULTILINESTRING equivalent column.
$table->multiPoint('positions'); MULTIPOINT equivalent column.
$table->multiPolygon('positions'); MULTIPOLYGON equivalent column.
$table->nullableMorphs('taggable'); Adds nullable versions of morphs() columns.
$table->nullableTimestamps(); Alias of timestamps() method.
$table->point('position'); POINT equivalent column.
$table->polygon('positions'); POLYGON equivalent column.
$table->rememberToken(); Adds a nullable remember_token VARCHAR(100) equivalent
column.
$table->smallIncrements('id'); Auto-incrementing UNSIGNED SMALLINT (primary key)
equivalent column.
$table->smallInteger('votes'); SMALLINT equivalent column.
$table->softDeletes(); Adds a nullable deleted_at TIMESTAMP equivalent column for
soft deletes.
$table->softDeletesTz(); Adds a nullable deleted_at TIMESTAMP (with timezone)
equivalent column for soft deletes.
$table->string('name', 100); VARCHAR equivalent column with a optional length.
$table->text('description'); TEXT equivalent column.
$table->time('sunrise'); TIME equivalent column.
$table->timeTz('sunrise'); TIME (with timezone) equivalent column.
$table->timestamp('added_on'); TIMESTAMP equivalent column.
$table->timestampTz('added_on'); TIMESTAMP (with timezone) equivalent column.
$table->timestamps(); Adds nullable created_at and updated_at TIMESTAMP equivalent
columns.
$table->timestampsTz(); Adds nullable created_at and updated_at TIMESTAMP (with
timezone) equivalent columns.
$table->tinyIncrements('id'); Auto-incrementing UNSIGNED TINYINT (primary key)
equivalent column.
$table->tinyInteger('votes'); TINYINT equivalent column.
$table->unsignedBigInteger('votes'); UNSIGNED BIGINT equivalent column.
$table->unsignedDecimal('amount', 8, 2); UNSIGNED DECIMAL equivalent column with a
precision (total digits) and scale (decimal digits).
$table->unsignedInteger('votes'); UNSIGNED INTEGER equivalent column.
$table->unsignedMediumInteger('votes'); UNSIGNED MEDIUMINT equivalent column.
$table->unsignedSmallInteger('votes'); UNSIGNED SMALLINT equivalent column.
$table->unsignedTinyInteger('votes'); UNSIGNED TINYINT equivalent column.
$table->uuid('id'); UUID equivalent column.
$table->year('birth_year'); YEAR equivalent column.
$table->string('email')->unique();
$table->unique('email');
```
CLEAR ALL BROWSERS:
erase "%TEMP%\*.*" /f /s /q
for /D %%i in ("%TEMP%\*") do RD /S /Q "%%i"
erase "%TMP%\*.*" /f /s /q
for /D %%i in ("%TMP%\*") do RD /S /Q "%%i"
erase "%ALLUSERSPROFILE%\TEMP\*.*" /f /s /q
for /D %%i in ("%ALLUSERSPROFILE%\TEMP\*") do RD /S /Q "%%i"
erase "%SystemRoot%\TEMP\*.*" /f /s /q
for /D %%i in ("%SystemRoot%\TEMP\*") do RD /S /Q "%%i"
@rem Clear IE cache - (Deletes Temporary Internet Files Only)
RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 8
erase "%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Microsoft\Windows\Tempor~1\*") do RD /S /Q "%%i"
@rem Clear Google Chrome cache
erase "%LOCALAPPDATA%\Google\Chrome\User Data\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Google\Chrome\User Data\*") do RD /S /Q "%%i"
@rem Clear Firefox cache
erase "%LOCALAPPDATA%\Mozilla\Firefox\Profiles\*.*" /f /s /q
for /D %%i in ("%LOCALAPPDATA%\Mozilla\Firefox\Profiles\*") do RD /S /Q "%%i"
pause
$ cat .htaccess_production
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Redirect to https
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,N]
<IfModule mod_headers.c>
# Activate HSTS
Header always set Strict-Transport-Security "max-age=31536000;
includeSubDomains; preload;"
Header always set Referrer-Policy "no-referrer"
Header always set X-Content-Type-Options "nosniff"
Header always set X-Download-Options "noopen"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Permitted-Cross-Domain-Policies "none"
Header always set X-Robots-Tag "none"
Header always set X-XSS-Protection "1; mode=block"
# Assets expire after 1 month
<filesMatch ".(css|js|woff2?|json)$">
Header set Cache-Control "public, max-age=2628000"
</filesMatch>
# Images expire after 6 months
<filesMatch ".(svg|png|gif|ico|jpe?g)$">
Header set Cache-Control "public, max-age=15768000"
</filesMatch>
</IfModule>
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>