1

I would like to know how to register a dependency when creating laravel package.

In my package composer.json I have :

{ "name": "facilinfo/gallery", "description": "Photo galleries management package for laravel", "type": "library", "license": "MIT", "keywords": ["laravel"], "authors": [ { "name": "facilinfo", "email": "[email protected]" } ], "minimum-stability": "stable", "require": { "laravelcollective/html": "5.2.*", "intervention/image": "dev-master" }, "autoload": { "psr-4": { "Facilinfo\\Gallery\\": "src/" } } } 

And when I do

$form = new Form(); 

I have a Class not found error.

How can I solve it?

4
  • Are you trying to autoload your own files or is the Form you're trying to use some third party lib? Commented Dec 31, 2015 at 12:21
  • I am trying to use the Collective Form in a view of my package. Commented Dec 31, 2015 at 12:26
  • It's probably a namespace issue. Try $form = new \Form(); Commented Dec 31, 2015 at 21:31
  • Finally, I found the soultion myself. I had tout add this to my package service provider: code $this->app->register(\Collective\Html\HtmlServiceProvider::class); $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Form', '\Collective\Html\FormFacade');code and to add "laravelcollective/html": " 5.2.*" in the laravel installation where I'm developping my package and install in. It works now. Commented Jan 2, 2016 at 12:03

1 Answer 1

2

Finally, I found the soultion myself. I had tout add this to my package service provider register function:

 $this->app->register(\Collective\Html\HtmlServiceProvider::class); $loader = \Illuminate\Foundation\AliasLoader::getInstance(); $loader->alias('Form', '\Collective\Html\FormFacade'); 

and to add "laravelcollective/html": " 5.2.*" in the laravel installation where I'm developping my package and install in. It works now.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.