Introduction to Laravel for web developers

Laravel is an opinionated MVC web framework for PHP. A typical application build using this framework consist of routes, controller, model and migrations.

Dependency management – Composer

Composer is the dependency management tool for Php. It is strongly inspired by node’s npm and ruby’s bundler. Laravel uses it to install and update dependencies. composer.json contains meta data about the dependencies and they are installed within the vendor/ directory at the root of the application.

Versioning

Laravel uses paradigm.minor.patch versioning for the framework. paradigm here, represents the architectural changes. But for the framework components, it uses the standard semantic version.

CLI

Laravel has its own CLI system called Artisan. Using it, you can create a project with a single command.

laravel new <project_name>

You can also create standard components of applications like controller, middleware, model in seconds, using it.

ORM

By default, the framework provides Eloquent with ActiveRecord implementation for working with database. This is really handy to do CRUD operations real quick. It also adds defaults like created_at and updated_at for every table created.

As with any other framework, laravel too does the following things.

  • Boiler plate generation
    • It generates boiler plate code for all the project components. For instance, --resource generates a controller with methods for all the HTTP verb.
  • Enforcing structure to the project.
    • middleware goes inside app/Http/Middleware
    • controller goes inside app/Http/Controllers
    • database/ for the migration and seed.
  • Naming convention for the components
    • Controller suffix is appended to generated suffix.
  • Forces standards
    • .env for the storing the configuration of the respective environment.