D
D
dk-web2015-10-15 13:51:21
Laravel
dk-web, 2015-10-15 13:51:21

I can't find where I "didn't put a comma" when developing a package for lAravel 5.1?

It seems that I am doing everything right, but my ServiceProvider does not find ...

FatalErrorException in ProviderRepository.php line 146:
Class 'DkWeb\Stats\StatsServiceProvider' not found

1. In the vendor folder, I made packages/DkWeb/Stats subfolders
2. in the config/app.php file, added the provider
App\Providers\RouteServiceProvider::class,
DkWeb\Stats\StatsServiceProvider::class,
3. composer.json in the package folder
{
    "name": "dkweb/stats",
    "description": "getting data from API",
    "license": "MIT",
    "authors": [
        {
            "name": "DkWeb",
            "email": "[email protected]"
        }
    ],
    "require": {},
    "autoload": {
        "classmap": [],
        "files": [],
        "psr-4": {
            "DkWeb\\Stats": "src/"
    }
}
}

4. composer.json at root:
"autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/",
            "DkWeb\\Stats\\": "packages/DkWeb/Stats/src"
        }
    },

5. The provider itself:
<?php
namespace DkWeb\Stats;
use Illuminate\Support\ServiceProvider;
class StatsServiceProvider extends ServiceProvider
{
  public function register()
  {
    $this->app->bind('Stats', function () {
      return new Stats;
    });
  }
  public function boot(){
    require __DIR__ . '/Http/routes.php';
  }

}

What spell didn't he say?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dk-web, 2015-10-15
@dk-web

Hmm ... the error turned out to be even more fun - I created the packages folder in the vendor folder ... but it was necessary at the root ..
inattention (

A
Andrey Mokhov, 2015-10-15
@mokhovcom

3. composer.json in package folder

extra closing curly brace?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question