Below are some points that should be kept in mind while making laravel project live.
1. php artisan optimize:clear
composer install --optimize-autoloader --no-dev
composer dump-autoload --optimize
Laravel Telescope: If you have installed packages like Laravel Telescope
or Debugbar
, you should disable or remove them in production: To remove run below command
composer remove laravel/telescope barryvdh/laravel-debugbar
Use Composer to check for any known security vulnerabilities in your dependencies:
composer audit
2. In the .env file
APP_DEBUG=false.
APP_ENV=production
3. In the app.php
$envKeys = [];
$serverKeys = [];
$cookieKeys = [];
foreach ( $_ENV as $key => $value ) { if(is_string($value)) $envKeys[] = $key; }
foreach ( $_SERVER as $key => $value ) { if(is_string($value)) $serverKeys[] = $key; }
foreach ( $_COOKIE as $key => $value ) { if(is_string($value)) $cookieKeys[] = $key; }
Inside return [
'debug_blacklist' => [
'_COOKIE' => $cookieKeys,
'_SERVER' => $serverKeys,
'_ENV' => $envKeys,
],
4. .htaccess
<Files ~ "\.(git|env|json|config.js|md|gitignore|gitattributes|lock|example)$">
Order allow,deny
Deny from all
</Files>
<Files ~ "(artisan)$">
Order allow,deny
Deny from all
</Files>
5. Remove tests folder from project.
No comments:
Post a Comment