Mark Fee
Mark Fee

Reputation: 122

Laravel 4 custom package not appearing in autoload_namespace.php

Laravel 4 custom package not appearing in autoload_namespace.php

I have tried to create a custom package by creating a workbench package in one of my laravel apps, committing it to github and then installing it in a different package. My problem is that the namespace map is not being added to autoload_namespace.php and the knock on effect of this is that the line Markfee\Responder\ResponderServiceProvider in my providers array causes the following error when i run:

php artisan dump-autoload

Error Output:

PHP Fatal error: Class 'Markfee\Responder\ResponderServiceProvider' not found in /media/sf_wwwshare/feenance/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157

The package can be found at:

https://github.com/markfee/responder.git

I include the package with the following entries in my composer.json file

"repositories": {
  "responder": {
    "type": "package",
    "package": {
      "name": "markfee/responder",
      "description": "Simple responder class for responding with json from api",
      "version": "0.1.0",
      "source": {
        "type": "git",
        "url": "https://github.com/markfee/responder.git",
        "reference": "a7a24c82479fc01ec0c06833690bfd2eeee9e47d"
      }
    }
  }
},
"require": {
  "laravel/framework": "4.2.*",
  "markfee/responder": "0.1.*"
},

If anyone can shed any light I'd be very greatful. Please ask if you need any further details.

Upvotes: 0

Views: 143

Answers (2)

Mark Fee
Mark Fee

Reputation: 122

with help from Sven I got this working, the exact changes I made were to replace the original entry in my composer.json with the following. I didn't use an alias as I just want to include the master branch at the moment. Versioning and adding to packagist are my next task:

"repositories": {
  "responder": {
    "type": "vcs",
    "url": "https://github.com/markfee/responder.git"
  }
},
"require": {
  "laravel/framework": "4.2.*",
  "markfee/responder": "dev-master"
},

Upvotes: 0

Sven
Sven

Reputation: 70863

You did the complicated way by providing a package definition for that repository. If you do that, this package is a complete replacement for any composer.json in that repository, and this should only be used in case there is none.

You didn't add the autoloading definition into that package, so it is correctly missing in your autoloading.

Suggestion: Avoid using type:package in your own composer.json file. Simply use type:vcs if the repository already has a composer.json.

If you want to use the master branch just like a tagged version, you can add an alias in your require statement: "markfee/responder": "dev-master as 0.1.0". You could also clone that repo and tag the commit you want in your own local copy, and reference your own repo instead. Or try to convince the maintainer to tag a version and add his repo to packagist.org.

Upvotes: 1

Related Questions