IoC Container


The Laravel inversion of control container is a powerful tool for managing class dependencies. Dependency injection is a method of removing hard-coded class dependencies. Instead, the dependencies are injected at run-time, allowing for greater flexibility as dependency implementations may be swapped easily.

Understanding the Laravel IoC container is essential to building a powerful, large application, as well as for contributing to the Laravel core itself.

Best Laravel Packages

Best Laravel Packages to speed up development

Presentation and transformation layer for complex data output such as RESTful APIs.

Self-validating smart models for Laravel Framework 4’s Eloquent ORM.

Unit testing & Full Stack Testing great for TDD.

PHP library that generates fake data for your project.

Light-weight hierarchical and instrumentation based profiler.

Laravel IDE Helper, generates correct PHPDocs for all Facade classes.

Changes For Laravel 4.2.*

$php artisan changes

-> View and Pagination ‘Environment’ classes renamed to ‘Factory’.
-> Configurable encryption for queue messages.
-> Make FrameGuard middleware opt-in.
-> Convert View ‘$errors’ shared variable into ViewErrorBag. Allows multiple bags per view. Should be backwards compatible.
-> Calling ‘create’ on a HasOne or HasMany relation will now use ‘fill’ method so mutators are executed on related model.
-> Use rawurldecode when decoding parameters in Route::parameters.
-> When date_format validation rule is used, before and after validation dates must match given format.
-> Added ability to register global Eloquent scopes using traits and addGlobalScope.
-> Soft deleting converted to use new global scope facilities.
-> Added ability to extend Eloquent Builder using ‘macro’ method.
-> Soft deleting models now use SoftDeletingTrait instead of softDelete property.
-> The queue:listen command will now write the names of the jobs it processes to the console.
-> Added Mailgun API transport for Mail::send. Depends on new ‘services’ configuration file.
-> Added Mandrill API transport for Mail::send. Depends on new ‘services’ configuration file.
-> Added ‘log’ mail transport for Mail::send. Writes raw MIME string to log files.
-> Added simplePaginate method to query and Eloquent builder.
-> Destructive migration operations now require confirmation or –force when being run in production.
-> Added Cache::pull method for retrieving a value and then deleting it.
-> Added Session::pull method for retrieving a value and then deleting it.
-> Added rel attribute to basic pagination links.
-> The ‘page’ query variable is now ignored when calling the paginator ‘appends’ method.
-> Empty arrays that are ‘required’ validate as false when empty.
-> Added –daemon option to the queue:work command.
-> Added convenient traits for authentication and password reminding.
-> Added ‘reject’ method to Collection.
-> Added ‘updateOrCreate’ method to Eloquent model.
-> Added ‘keyBy’ method to Collection.
-> Added ‘contains’ method to base Collection.
-> Allow ‘where’ route constraints to be passed in array definition of Route.
-> Properly support Route ‘where’ constraints on a Route group.
-> When ‘increment’ or ‘decrement’ is called on a single Model instance, the local attribute value is updated as well.
-> Automatically retry queries on database connections that have ‘gone away’.

work of Laravel framework

  • Laravel has a lot of core components
  • When any request hits the Laravel framework, it bootstraps and loads its Application class
  • Laravel’s Application class extends the container class, so the container class is also loaded
  • Framework loads and executes the register method of all the service providers that are in the providers array at app/config/app.php
  • Each service provider by the Laravel packages has a registered method that binds each of the package classes with the IoC container
  • Once each package is bound with the IoC container, you can use packages such as Auth, Cache, and Log in your application