Artisan不会在制作中工作,但在当地工作正常

时间:2016-06-24 14:05:41

标签: laravel artisan

我正在解决生产中的问题:我无法让我的迁移运行。而且,不仅如此,只是运行'php artisan'会产生错误。奇怪的是,一切都在当地运作良好。

我正在使用Laravel 5.1,并尝试在服务器上重新克隆我的应用程序,重新安装供应商(刷新作曲家缓存后),重做.env并授予相应的引导程序/缓存和存储文件的权限。我还手动删除了所有表,然后,当它不起作用时,删除并重新创建数据库本身。我曾多次运行'composer dump-autoload',因为我试图孤立问题的根源而没有运气。

我查看了我的日志文件,这就是出现的结果:

[2016-06-24 06:07:16] production.ERROR: exception 'ErrorException' with message 'Trying to get property of non-object' in /var/www/html/foobooks/app/Services/PrivacyService.php:157
Stack trace:
#0 /var/www/html/foobooks/app/Services/PrivacyService.php(157): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', '/var/www/html/l...', 157, Array)
#1 /var/www/html/foobooks/app/Services/DateService.php(69): Foobooks\Services\PrivacyService->getPrivacyLevelIdWithPrivacyLevel('everyone')
#2 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(239): Foobooks\Services\DateService->Foobooks\Services\{closure}()
#3 [internal function]: Illuminate\Cache\Repository->rememberForever('everyone_privac...', Object(Closure))
#4 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Cache/CacheManager.php(318): call_user_func_array(Array, Array)
#5 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(217): Illuminate\Cache\CacheManager->__call('rememberForever', Array)
#6 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(217): Illuminate\Cache\CacheManager->rememberForever('everyone_privac...', Object(Closure))
#7 /var/www/html/foobooks/app/Services/DateService.php(70): Illuminate\Support\Facades\Facade::__callStatic('rememberForever', Array)
#8 /var/www/html/foobooks/app/Services/DateService.php(70): Illuminate\Support\Facades\Cache::rememberForever('everyone_privac...', Object(Closure))
#9 [internal function]: Foobooks\Services\DateService->__construct(Object(Foobooks\Repositories\Models\DbEventRepository), Object(Foobooks\Services\PrivacyService), Object(Foobooks\$
#10 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(780): ReflectionClass->newInstanceArgs(Array)
#11 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('Foobooks\...', Array)
#12 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('Foobooks\...', Array)
#13 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(220): Illuminate\Foundation\Application->make('Foobooks\...', Array)
#14 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(738): Illuminate\Container\Container->Illuminate\Container\{closure}(Object(Illuminate\Foundation\Application), Array)
#15 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build(Object(Closure), Array)
#16 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('Foobooks\...', Array)
#17 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(842): Illuminate\Foundation\Application->make('Foobooks\...')
#18 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#19 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(776): Illuminate\Container\Container->getDependencies(Array, Array)
#20 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('Foobooks\...', Array)
#21 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('Foobooks\...', Array)
#22 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Console/Application.php(115): Illuminate\Foundation\Application->make('Foobooks\...')
#23 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Console/Application.php(129): Illuminate\Console\Application->resolve('Foobooks\...')
#24 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(226): Illuminate\Console\Application->resolveCommands(Array)
#25 /var/www/html/foobooks/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Illuminate\Foundation\Console\Kernel->getArtisan()
#26 /var/www/html/foobooks/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 {main}

该应用程序似乎实际上是尝试在自动加载进程中的某个地方实例化我的类DateService(这反过来实例化PrivacyService),这就是造成问题的原因。我已经在我的应用程序中搜索了它被注入的所有实例,但似乎没有一个是自动加载过程的一部分 - 而且,它并不能解释为什么事情在本地工作得很好。

最初,当工匠抱怨时,它给了我一个'缺少基表错误',无论出于何种原因,如果我'假'在数据库中创建表然后手动删除它,应用程序继续抱怨另一个表直到我再次手动创建/删除。我能够以这种方式移动表错误,直到我点击“试图获取非对象属性”错误。

有没有人知道可能是什么问题?感觉就像某种类型的数据库缓存文件,我不知道它在某处悬挂并导致此问题,使应用程序认为迁移/种子已经发生。看起来奇怪的是,创建假表并丢弃它们似乎正在做一些事情,直到出现这个错误 - 同样,奇怪的是只有生产环境受到影响。

非常感谢任何帮助或见解 - 谢谢!

1 个答案:

答案 0 :(得分:0)

解决方案:由于某种原因,我的缓存文件夹中的某些文件夹的权限与其他文件夹不同,因此flush()方法未完全清除缓存。传统文件夹/文件与工匠的自举工作相冲突。我能够通过重新应用存储/框架/缓存目录的权限,再次运行flush()来解决问题。一旦我做了并确保从缓存中删除了所有子文件夹和文件,我就能毫无障碍地运行php artisan。