The Meaning Of Dependencies In Composer And Laravel Service Container
I am not familiar with composer and laravel.
according to the guide.
Composer is A Dependency Manager for PHP.
The Laravel service container is a powerful tool for managing class dependencies and performing dependency injection.
if composer manages a dependency, why service container is needed? they refer to different dependencies?
thanks in advance.
Answer
Composer deals with making copies of libraries available within the project at all. It ensures the libraries you have denoted as required are present in the vendor folder within your project. It doesn't know anything about you project or how these libraries are used, or if they are at all. Composer deals with which libraries your project depends on and makes sure they are available.
The Laravel service container deals with instantiating instances of classes at run time.
If you have a parameter to a constructor with a specific class type-hint, the service container is the piece which resolves that for you. e.g.
public function __construct(User $user)
{
$user;
}
The Laravel service container deals with run time dependencies and resolves classes in order to instantiates objects as needed.
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms