У меня проблемы с пользовательским пакетом композитора, который я создал для работы в Laravel.Я выполнил все необходимые шаги, которые другие сказали.Сначала требуется пакет, затем composer-dumpautoload -o
, а затем добавьте ServiceProvider
к config/app.php
.Однако laravel не может найти пакет ServiceProvider.Может быть, мое имя не включено?Вот мой код ниже вместе со ссылкой на мой репозиторий github
https://github.com/InspiredByKeith/forecast-package
config / app.php
KeithRoye\Forecast\WeatherServiceProvider::class,
WeatherServiceProvider.php
<?php
namespace KeithRoye\Forecast;
use Illuminate\Support\ServiceProvider;
class WeatherServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
$this->loadRoutesFrom(__DIR__.'/routes/web.php');
}
/**
* Register services.
*
* @return void
*/
public function register()
{
//
}
}
Композитор.json пакета
{
"name": "keithroye/forecast",
"description": "This package will allow users to obtain a 5 day weather forecast based upon the given zip code provided.",
"type": "library",
"require-dev": {
"guzzlehttp/guzzle": "^6.3@dev"
},
"autoload-dev": {
"psr-4": {
"KeithRoye\\Forecast": "src/"
}
},
"license": "MIT",
"authors": [
{
"name": "Keith Roye",
"email": "inspiredbykeith@gmail.com"
}
],
"minimum-stability": "dev"
}
Композитор.json Приложения
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"keithroye/forecast": "dev-master",
"laravel/framework": "5.7.*",
"laravel/tinker": "^1.0"
},
"require-dev": {
"beyondcode/laravel-dump-server": "^1.0",
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.4",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}