找不到Laravel服务提供程序类 - 特定于服务器的问题

时间:2015-10-06 01:52:26

标签: laravel namespaces packages

我正在为Laravel 5创建自定义程序包,并且遇到了Laravel无法为此找到服务提供程序的问题,但仅限于特定服务器上。在本地,我使用Homestead框在Vagrant下运行它,并且它正常工作。使用git将它推送到dreamhost VPS(Ubuntu),它给了我错误,它不能使用Figoliquinn \ Quickbooksconnect \ QuickbooksconnectServiceProvider类。这对我来说感觉就像一个命名空间问题,因为它在不同的环境中工作方式不同,但我还没能找到原因。

包的文件夹结构是(来自laravel根目录):

* packages
|--* figoliquinn
   |--* quickbooksconnect
   |--* src
      |--* QuickbooksconnectServiceProvider.php

QuickbooksconnectServiceProvider.php

    <?php namespace Figoliquinn\Quickbooksconnect;

use Figoliquinn\Quickbooksconnect;

use Illuminate\Support\ServiceProvider;
use Illuminate\Routing\Router;

class QuickbooksconnectServiceprovider extends ServiceProvider {


    /**
     * Indicates if loading of the provider is deferred.
     *
     * @var bool
     */
    protected $defer = false;

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {   
        // Get the views we'll need
        $this->loadViewsFrom(__DIR__ . '/views', 'quickbooksconnect');

        // Register our controller and routes
        $this->app->router->group(['namespace' => 'Figoliquinn\Quickbooksconnect\Controllers'],
        function(){
            require __DIR__.'/routes.php';
        });
    }


    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {

    }

}

这是我的composer.json文件在Laravel根目录中的样子:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "illuminate/html": "~5.0",
        "guzzlehttp/guzzle": "~5.3|~6.0",
        "doctrine/dbal": "~2.3"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/",
            "Figoliquinn\\Quickbooksconnect\\": "packages/figoliquinn/quickbooksconnect/src/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ],
        "files": [
            "app/helpers.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

然后在config / app.php中添加它时,这看起来像(缩写为提供者部分):

'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
        Illuminate\Auth\AuthServiceProvider::class,
        Illuminate\Broadcasting\BroadcastServiceProvider::class,
        Illuminate\Bus\BusServiceProvider::class,
        Illuminate\Cache\CacheServiceProvider::class,
        Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
        Illuminate\Routing\ControllerServiceProvider::class,
        Illuminate\Cookie\CookieServiceProvider::class,
        Illuminate\Database\DatabaseServiceProvider::class,
        Illuminate\Encryption\EncryptionServiceProvider::class,
        Illuminate\Filesystem\FilesystemServiceProvider::class,
        Illuminate\Foundation\Providers\FoundationServiceProvider::class,
        Illuminate\Hashing\HashServiceProvider::class,
        Illuminate\Mail\MailServiceProvider::class,
        Illuminate\Pagination\PaginationServiceProvider::class,
        Illuminate\Pipeline\PipelineServiceProvider::class,
        Illuminate\Queue\QueueServiceProvider::class,
        Illuminate\Redis\RedisServiceProvider::class,
        Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
        Illuminate\Session\SessionServiceProvider::class,
        Illuminate\Translation\TranslationServiceProvider::class,
        Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,
        'Illuminate\Html\HtmlServiceProvider',
        'Figoliquinn\Quickbooksconnect\QuickbooksConnectServiceProvider',

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
        'App\Providers\MacrosServiceProvider',
        'App\Providers\CurrentOrgServiceProvider',

    ],

对我可能忽略的事情有任何建议吗?

1 个答案:

答案 0 :(得分:0)

让我真的变得愚蠢。我包含了或多或少的SDK,我试图将其集成到一个软件包中,而且该SDK有一个.gitignore文件,该文件导致了一些问题。删除它就可以了。