一旦我进行 Composer 安装或 Composer 更新,我更喜欢安装,因为基本脚本是 2017 年的。然后我得到了这个。
FatalThrowableError in Inflector.php line 70:
Class 'Doctrine\Inflector\InflectorFactory' not found
in Inflector.php line 70
at Inflector::createFactory() in Inflector.php line 58
at Inflector::getInstance() in Inflector.php line 279
at Inflector::singularize('members') in Pluralizer.php line 77
at Pluralizer::singular('members') in Str.php line 344
at Str::singular('members') in ResourceRegistrar.php line 268
at ResourceRegistrar->getResourceWildcard('members') in ResourceRegistrar.php line 91
at ResourceRegistrar->register('members', 'AdminController', array('names' => array('edit' => 'user.edit', 'destroy' => 'user.destroy'))) in Router.php line 290
at Router->resource('members', 'AdminController', array('names' => array('edit' => 'user.edit', 'destroy' => 'user.destroy'))) in ResourceRegistrar.php line 116
at ResourceRegistrar->Illuminate\Routing\{closure}(object(Router))
at call_user_func(object(Closure), object(Router)) in Router.php line 330
at Router->group(array('prefix' => 'panel/admin'), object(Closure)) in ResourceRegistrar.php line 119
at ResourceRegistrar->prefixedResource('members', 'AdminController', array('names' => array('edit' => 'user.edit', 'destroy' => 'user.destroy'))) in ResourceRegistrar.php line 83
at ResourceRegistrar->register('panel/admin/members', 'AdminController', array('names' => array('edit' => 'user.edit', 'destroy' => 'user.destroy'))) in Router.php line 290
at Router->resource('panel/admin/members', 'AdminController', array('names' => array('edit' => 'user.edit', 'destroy' => 'user.destroy'))) in Facade.php line 237
at Facade::__callStatic('resource', array('panel/admin/members', 'AdminController', array('names' => array('edit' => 'user.edit', 'destroy' => 'user.destroy')))) in web.php line 218
at RouteServiceProvider->{closure}(object(Router))
at call_user_func(object(Closure), object(Router)) in Router.php line 330
at Router->group(array('middleware' => 'role'), object(Closure)) in Facade.php line 237
at Facade::__callStatic('group', array(array('middleware' => 'role'), object(Closure))) in web.php line 255
at require('/data01/myserver/htdocs/routes/web.php') in RouteServiceProvider.php line 58
at RouteServiceProvider->App\Providers\{closure}(object(Router))
at call_user_func(object(Closure), object(Router)) in Router.php line 330
at Router->group(array('middleware' => 'web', 'namespace' => 'App\Http\Controllers'), object(Closure)) in Facade.php line 237
at Facade::__callStatic('group', array(array('middleware' => 'web', 'namespace' => 'App\Http\Controllers'), object(Closure))) in RouteServiceProvider.php line 59
at RouteServiceProvider->mapWebRoutes() in RouteServiceProvider.php line 38
at RouteServiceProvider->map()
at call_user_func_array(array(object(RouteServiceProvider), 'map'), array()) in Container.php line 508
at Container->call(array(object(RouteServiceProvider), 'map')) in RouteServiceProvider.php line 69
at RouteServiceProvider->loadRoutes() in RouteServiceProvider.php line 30
at RouteServiceProvider->boot() in RouteServiceProvider.php line 28
at RouteServiceProvider->boot()
at call_user_func_array(array(object(RouteServiceProvider), 'boot'), array()) in Container.php line 508
at Container->call(array(object(RouteServiceProvider), 'boot')) in Application.php line 769
at Application->bootProvider(object(RouteServiceProvider)) in Application.php line 752
at Application->Illuminate\Foundation\{closure}(object(RouteServiceProvider), '18')
at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FoundationServiceProvider), object(NotificationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ViewServiceProvider), object(ImageServiceProvider), object(ImageValidatorServiceProvider), object(CashierServiceProvider), object(AppServiceProvider), object(AuthServiceProvider), object(EventServiceProvider), object(RouteServiceProvider), object(TranslationServiceProvider), object(ValidationServiceProvider)), object(Closure)) in Application.php line 753
at Application->boot() in BootProviders.php line 17
at BootProviders->bootstrap(object(Application)) in Application.php line 203
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 254
at Kernel->bootstrap() in Kernel.php line 145
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
at Kernel->handle(object(Request)) in index.php line 53
我不知道它为什么会来。我认为这是因为更新,因为它需要最新的等等。但即使安装了我也得到了这个。
Composer.json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"laravel/framework": "5.3.*",
"intervention/image": "^2.3",
"cviebrock/image-validator": "^2.0",
"laravelcollective/html": "5.3.*",
"laravel/cashier": "~7.0"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.*",
"symfony/dom-crawler": "3.1.*",
"fahim/laravel5-paypal-ipn": "dev-master@dev",
"maksekeskus/maksekeskus-php": "v1.4.2"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"app/helper.php"
]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
我唯一不能做的就是使用 php 5.6,因为我的服务提供商不会那么低。我可以使用的最旧的是 7.0
我已将您的
composer.json
文件与您的 Laravel 版本的官方“JSON”文件进行了比较,它看起来状态良好。
原始 Laravel v5.3.*composer.json 文件
请仅在必要时运行
composer update
。从这里了解 composer update
和 composer install
之间的区别。 composer 更新和composer 安装有什么区别?
从您的“错误日志”中,它抱怨缺少课程
Class 'Doctrine\Inflector\InflectorFactory' not found in Inflector.php line 70
。
相关文件位于
testProject\vendor\doctrine\inflector\lib\Doctrine\Common\Inflector\Inflector.php
。 “testProject”是我在尝试重现问题时的项目名称。import
语句即可轻松解决此问题,该类在我的测试用例中已存在。即 use Doctrine\Inflector\InflectorFactory;
Inflector.php
文件。
❌由于手动编辑位于项目根目录中的
vendor
文件夹 📂 中的文件通常是不好的做法,因此以下是我的建议。
composer.lock
文件。vendor
文件夹📂。composer clear-cache
composer update
app/helper.php
存在,因为我在您的自定义 composer.json
文件中看到了它。composer.json
文件中删除下面的 声明,因为我在测试时无法访问
app/helper.php
文件。// ...
,
"files": [
"app/helper.php"
]
// ...
php artian serve
并导航到浏览器中显示的输出 URL,以确认错误是否已消失。