Some Usefull Laravel Command

Laravel is a popular PHP web application framework that provides a set of useful features and tools for developing modern web applications. Here are some of the most commonly used Laravel commands:

  1. php artisan serve – Starts a development server to serve your Laravel application on your local machine.
  2. php artisan make:model ModelName – Creates a new model class in the app/Models directory.
  3. php artisan make:controller ControllerName – Creates a new controller class in the app/Http/Controllers directory.
  4. php artisan make:migration create_table_name – Creates a new database migration file in the database/migrations directory.
  5. php artisan migrate – Runs all pending database migrations.
  6. php artisan tinker – Opens the Laravel REPL (Read-Eval-Print Loop) which allows you to interact with your Laravel application’s code and data in real-time.
  7. php artisan make:middleware MiddlewareName – Creates a new middleware class in the app/Http/Middleware directory.
  8. php artisan make:auth – Generates basic login and registration views and controllers for authentication.
  9. php artisan route:list – Lists all the registered routes for your Laravel application.
  10. php artisan optimize Optimizes the application by generating a compiled class file to speed up the application’s performance.
  11. php artisan view:cacheThis command is used to cache all of your application’s views, which can help to improve the loading time of your web pages. Once the views are cached, Laravel will use the cached versions instead of compiling them from the source files on each request.
  12. php artisan config:cache This command is used to cache all of your application’s configuration files, which can help to improve the overall performance of your application by reducing the time it takes to load configuration values. Once the configuration files are cached, Laravel will use the cached versions instead of loading them from disk on each request.
  13. php artisan route:cache This command is used to cache all of your application’s routes, which can help to improve the performance of your application by reducing the time it takes to match incoming requests to the appropriate route. Once the routes are cached, Laravel will use the cached versions instead of loading them from disk on each request.
  14. php artisan optimize:clear command, Laravel will remove the compiled class file, and your application will revert to using the original class files, which will be loaded individually on each request. This can lead to slightly slower application performance, but it may be necessary in some situations to ensure that your application is running correctly.
  15. the sudo chmod -R 777 bootstrap/cache and sudo chmod -R 777 storage commands, you are setting the permissions of these directories and all their contents to 777, which means that all users and groups on the system will have full access to these directories and their contents.
  16. php artisan key:generate is a command used to generate a new application key in Laravel. The application key is a random string of characters used to encrypt data in your application, such as user sessions and authentication cookies. Running this command will generate a new key and update the APP_KEY value in your .env file.
  17. php artisan storage:link is a command used to create a symbolic link between the public directory and the storage/app/public directory in Laravel. This allows you to easily serve files stored in the storage/app/public directory through a URL, such as uploaded images or files. Once you run this command, files stored in the storage/app/public directory can be accessed through a URL like http://your-app.com/storage/filename.ext.
  18. php artisan migrate:refresh --seed is a command used to refresh the database migration and seed it with initial data in Laravel. Running this command will drop all tables in the database and then re-run all migrations and seed the database with initial data. This command is useful during development when you need to reset your database to its initial state.Keep in mind that running php artisan migrate:refresh –seed will delete all data in your database, so you should only use it during development and testing, not in a production environment. Additionally, before running this command, make sure you have a backup of your database to avoid losing any important data.
php artisan serve 
php artisan make:model ModelName 
php artisan make:controller ControllerName 
php artisan make:migration create_table_name 
php artisan migrate 
php artisan tinker 
php artisan make:middleware MiddlewareName
php artisan make:auth 
php artisan route:list 
php artisan optimize 
php artisan view:cache 
php artisan config:cache 
php artisan route:cache 
php artisan optimize:clear 
sudo chmod -R 777 bootstrap/cache and sudo chmod -R 777 storage 
php artisan key:generate 
php artisan storage:link 
php artisan migrate:refresh --seed 

These are just a few examples of the many commands available in Laravel. Each command is designed to simplify common development tasks and increase developer productivity.

Leave a Reply

Your email address will not be published. Required fields are marked *