Why Laravel Is The Best PHP Framework In 2018
- Artisan - A Command-Line Interface
- Migrations & Seeding
- Blade Template Engine
- Middleware - HTTP middleware provide a convenient mechanism for filtering HTTP requests entering your application.
- Eloquent ORM + Built-in Database Query Builder
- Routing (RESTful routing)
- Inbuilt packages - Authentication, Cashier, Scheduler, SSH, Socialite
- Unit Testing - Built-in unit testing and simply readable impressive syntax
- Caching - Laravel provides an expressive, unified API for various caching backends
You may also like - Top 50 Laravel Interview Questions
>> php artisan list //This will list all artisan command provided by laravel. Laravel Framework 5.4.21 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --env[=ENV] The environment the command should run under -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug Available commands: clear-compiled Remove the compiled class file down Put the application into maintenance mode env Display the current framework environment help Displays help for a command inspire Display an inspiring quote list Lists commands migrate Run the database migrations optimize Optimize the framework for better performance serve Serve the application on the PHP development server tinker Interact with your application up Bring the application out of maintenance mode app app:name Set the application namespace auth auth:clear-resets Flush expired password reset tokens cache cache:clear Flush the application cache cache:forget Remove an item from the cache cache:table Create a migration for the cache database table config config:cache Create a cache file for faster configuration loading config:clear Remove the configuration cache file db db:seed Seed the database with records event event:generate Generate the missing events and listeners based on registration key key:generate Set the application key make make:auth Scaffold basic login and registration views and routes make:command Create a new Artisan command make:controller Create a new controller class make:event Create a new event class make:job Create a new job class make:listener Create a new event listener class make:mail Create a new email class make:middleware Create a new middleware class make:migration Create a new migration file make:model Create a new Eloquent model class make:notification Create a new notification class make:policy Create a new policy class make:provider Create a new service provider class make:request Create a new form request class make:seeder Create a new seeder class make:test Create a new test class migrate migrate:install Create the migration repository migrate:refresh Reset and re-run all migrations migrate:reset Rollback all database migrations migrate:rollback Rollback the last database migration migrate:status Show the status of each migration notifications notifications:table Create a migration for the notifications table queue queue:failed List all of the failed queue jobs queue:failed-table Create a migration for the failed queue jobs database table queue:flush Flush all of the failed queue jobs queue:forget Delete a failed queue job queue:listen Listen to a given queue queue:restart Restart queue worker daemons after their current job queue:retry Retry a failed queue job queue:table Create a migration for the queue jobs database table queue:work Start processing jobs on the queue as a daemon route route:cache Create a route cache file for faster route registration route:clear Remove the route cache file route:list List all registered routes schedule schedule:run Run the scheduled commands session session:table Create a migration for the session database table storage storage:link Create a symbolic link from "public/storage" to "storage/app/public" vendor vendor:publish Publish any publishable assets from vendor packages view view:clear Clear all compiled view files
You may also like - MongoDB Interview Questions
- Migrations are like version control for your database, allowing your team to easily modify and share the application's database schema.
- Migrations are typically paired with Laravel's schema builder to easily build your application's database schema.
- If you have ever had to tell a teammate to manually add a column to their local database schema, you've faced the problem that database migrations solve.
The Laravel Schema facade provides database agnostic support for creating and manipulating tables across all of Laravel's supported database systems.
To create a migration use following artisan command: Create a migration for users table
php artisan make:migration create_users_table //OR php artisan make:migration create_users_table --table=users //OR php artisan make:migration create_users_table --create=usersThe new migration will be placed in your database/migrations directory
Note: Run specific migration in laravel -
php artisan migrate --path=/database/migrations/my_migration_file
- Blade is the simple, yet powerful templating engine provided with Laravel. Unlike other popular PHP templating engines, Blade does not restrict you from using plain PHP code in your views. In fact, all Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application.
- Blade view files use the .blade.php file extension and are typically stored in the resources/views directory.
- See in details on laravel official website
Middleware provide a convenient mechanism for filtering HTTP requests entering your application.
For example, Laravel includes a middleware that verifies the user of your application is authenticated. If the user is not authenticated, the middleware will redirect the user to the login screen. However, if the user is authenticated, the middleware will allow the request to proceed further into the application.
Of course, additional middleware can be written to perform a variety of tasks besides authentication. A CORS middleware might be responsible for adding the proper headers to all responses leaving your application. A logging middleware might log all incoming requests to your application.
There are several middleware included in the Laravel framework, including middleware for authentication and CSRF protection.
All of these middleware are located in the app/Http/Middleware directory.
To create a middleware use following artisan command: >> php artisan make:middleware CustomMiddleware //Note- CustomMiddleware is the name of the middleware
Authentication, Cashier, Scheduler, SSH, Socialite etc
You may also like - CakePHP Interview Questions
Easy to Maintain: Laravel follows a module structure and thus, you can easily maintain it. A laravel website requires the only minimal level of maintenance.
Rapid and Secure: Laravel speeds up your web development process and thus, it is considered the rapid development PHP framework. Laravel comes up with an array of secure authentication tools, so Laravel is a very secured framework.
Task Scheduling: In earlier, you need to generate Cron entry for each task that you need to schedule on your server. But Laravel provides you with the scheduler command which allows you to define your command schedule within Laravel itself.
Queues: Laravel queues provide you with a unified API across different queue backends like Beanstalk, Amazon SQS, Redis , etc. Queues help you in deferring time-consuming tasks like sending an email, and many more things. Since your time-consuming tasks are deferred, this will speed up your web requests to your application.
Events: Laravel events give you a simple observer implementation. This feature helps you to subscribe and listen to events in your application.
Notifications: Along with providing support for sending e-mail, Laravel provides you support for sending notifications in other channels also like SMS and Slack. Notifications can be stored in your database so that you can display them in your web interface.
Automatic Pagination: Laravel possesses automatic pagination which simplifies the task of implementation paginations. With laravel, you don’t need to use manual implementation.
Multiple File System: Laravel uses third-party package Flysystem to provide multiple file support for the developers. You can use any Local or Cloud-based storage in order to provide simple configuration.
Automatic Package Discovery: In earlier versions of Laravel, you can easily install packages. But Laravel 5.6 comes with a new feature called Automatic Package Discovery which detects the packages automatically which users want to install on their devices. Laravel 5.6 allows developers to disable this feature for some specific packages.
You may also like - PHP Developer Interview Questions