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:
php artisan serve– Starts a development server to serve your Laravel application on your local machine.
php artisan make:model ModelName– Creates a new model class in the
php artisan make:controller ControllerName– Creates a new controller class in the
php artisan make:migration create_table_name– Creates a new database migration file in the
php artisan migrate– Runs all pending database migrations.
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.
php artisan make:middleware MiddlewareName– Creates a new middleware class in the
php artisan make:auth– Generates basic login and registration views and controllers for authentication.
php artisan route:list– Lists all the registered routes for your Laravel application.
php artisan optimize– Optimizes the application by generating a compiled class file to speed up the application’s performance.
php artisan view:cache– This 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.
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.
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.
php artisan optimize:clearcommand, 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.
sudo chmod -R 777 bootstrap/cacheand
sudo chmod -R 777 storagecommands, 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.
php artisan key:generateis 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_KEYvalue in your
php artisan storage:linkis a command used to create a symbolic link between the
publicdirectory and the
storage/app/publicdirectory in Laravel. This allows you to easily serve files stored in the
storage/app/publicdirectory through a URL, such as uploaded images or files. Once you run this command, files stored in the
storage/app/publicdirectory can be accessed through a URL like
php artisan migrate:refresh --seedis 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.