Laravel 5从供应商那里加载自定义包



我正在尝试从供应商文件加载一个自定义软件包(lapisraro/autocrud(到我的项目,但是得到此错误:

" class'lapisraro autocrud autocrudServiceProvider'找不到"

这是我的应用程序的composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "lapisraro/autocrud": "dev-master",
        "laravel/framework": "5.8.*",
        "laravel/tinker": "^1.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "jeroen-g/laravel-packager": "^2.2",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^3.0",
        "phpunit/phpunit": "^7.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Lapisraro\Autocrud\": "/lapisraro/autocrud/src"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r "file_exists('.env') || copy('.env.example', '.env');""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

这是我的作曲家。

  {
    "name": "lapisraro/autocrud",
    "description": "Gerador de CRUD padrão da LapisRaro",
    "license": "MIT",
    "type": "library",
    "authors": [
        {
          "name": "Lucas Campos",
          "email": "lucasblind@gmail.com"
        }
      ],
    "minimum-stability": "dev",
    "autoload": {
      "psr-4": {
          "Lapisraro\Autocrud\": "src/"
      },
      "classmap": [
          "database/seeds",
          "database/factories"
      ]
    },
    "autoload-dev": {
      "psr-4": {
          "Tests\": "tests/",
          "Lapisraro\Autocrud\": "src/"
      }
  },
    "extra": 
    {
      "laravel": 
      {
          "providers": [ "Lapisraro\autocrud\AutocrudServiceProvider" ]
      }
    }
  }

这是我的服务提供商

<?php
    // MyVendorcontactformsrcContactFormServiceProvider.php
    namespace Lapisraroautocrud;
    use IlluminateSupportServiceProvider;

    use IlluminateHttpRequest;
    use IlluminateSupportFacadesRoute;
    use IlluminateSupportFacadesStorage;
    use YajraDataTablesFacadesDataTables;
    //use InterventionImageFacadesImage;
    //use AppModelsImage as ImgModel;
    class AutocrudServiceProvider extends ServiceProvider {
        /**
         * boot
         *
         * Initialize provider
         * 
         * @return void
         */
        public function boot()
        {
            $this->loadRoutesFrom(__DIR__.'/routes/web.php');
            $this->loadViewsFrom(__DIR__.'/resources/views', 'autocrud');
        }
        /**
         * register
         *
         * Register the service provider for the dependency.
         * 
         * @return void
         */
        public function register()
        {
            $this->loadRoutesFrom(__DIR__.'/routes/web.php');
            $this->loadViewsFrom(__DIR__.'/resources/views', 'autocrud');
            //App::register(AutocrudServiceProvider::class);
        }
    }
    ?>

我还尝试在config/app.php中加载该加载:

LapisraroAutocrudAutocrudServiceProvider::class,

和我的软件包的此链接https://packagist.org/packages/lapisraro/autocrud

,而不是在您的应用程序的composer.json中自动加载PSR-4

"autoload": {
    "psr-4": {
        "App\": "app/",
        "Lapisraro\Autocrud\": "/lapisraro/autocrud/src"
    },

...这样的repositories添加您的本地软件包:

"repositories": [
    {
        "type": "path",
        "url": "/lapisraro/autocrud"
    }
]

之后运行composer updatecomposer dump-autoload

我放弃了,试图用laravel-packager做这个,但也不工作但是我发现了这个视频https://www.youtube.com/watch?v=h-eunqekaca,现在它的工作。

问题是在作曲家文件和文件夹级别中。

感谢您的帮助!

相关内容

  • 没有找到相关文章

最新更新