Jerielle
Jerielle

Reputation: 7520

How to include ServiceProviders in Laravel 5 manually?

I just want to ask a question. I just want to ask if there's a way to include ServiceProviders in Laravel manually? I looked in github page and I saw some laravel serviceprovider. How can I include those in my laravel file? I am new to laravel and I am studying this in our home without an Internet connection. I downloaded the HTMLServiceProvideer manually and I also tried the command:

composer require illuminate/html 

Can the composer run without having an Internet Connection? If no how can I install a serviceprovider by using the master-files? Where should I place the files and what file should I need to update?

Upvotes: 1

Views: 688

Answers (2)

Emeka Mbah
Emeka Mbah

Reputation: 17553

I believe this is possible but you need to manually do the work of the Composer. So for instance lets assume want to manually install illuminate/html package.

You can follow these steps:

  1. Add "illuminate/html": "5.*" to your composer.json although we are not using Composer for installing this package, its important we have this listed in composer.json should in case we run 'composer update' in the future our manually added package will not be deleted but rather updated.

"require":{  
        "laravel/framework": "5.0.*",  
        "illuminate/html": "5.*"  
    }
  1. Manually download the package from Github and place the package inside vendor directory which is located at the root of your laravel application

example in mylaravelapp/vendor

  1. Add the package to mylaravelapp/vendor/composer/autoload_namespaces.php


return array(  
    .....  
    'Illuminate\\Html\\' => array($vendorDir . '/illuminate/html'),  
);

  1. Add the package to mylaravelapp/vendor/composer/autoload_namespaces.php

return array(  
    ....  
    'Illuminate\\Html\\' => array($vendorDir . '/illuminate/html'),  
);
  1. Run composer dump-autoload to check for errors

  2. Add Package service provider in config/app.php 'providers' => []

  3. Run composer dump-autoload once more

Upvotes: 1

Borjante
Borjante

Reputation: 10517

Service Providers are added to your config/app.php

But you will need to have that package downloaded...

Upvotes: 1

Related Questions