I was trying to publish my new laravel project using Forge+DigitalOcean but I get the error message (We were unable to install a project on your server) due to php artisan optimize command returning Invalid filename provided. error.
So I modified my .env file and set APP_DEBUG to false and tried to run the command locally. I got the following error:
php artisan optimize -v
Generating optimized class loader Compiling common classes
[RuntimeException] Invalid filename provided.
Exception trace: () at /home/bubut/Code/TalalAttendance/vendor/classpreloader/classpreloader/src/ClassPreloader.php:105
ClassPreloader\ClassPreloader->getCode() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php:89
Illuminate\Foundation\Console\OptimizeCommand->compileClasses() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Foundation/Console/OptimizeCommand.php:70
Illuminate\Foundation\Console\OptimizeCommand->fire() at n/a:n/a
call_user_func_array() at
/home/bubut/Code/TalalAttendance/bootstrap/cache/compiled.php:1138
Illuminate\Container\Container->call() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Console/Command.php:150
Illuminate\Console\Command->execute() at
/home/bubut/Code/TalalAttendance/vendor/symfony/console/Command/Command.php:258
Symfony\Component\Console\Command\Command->run() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Console/Command.php:136
Illuminate\Console\Command->run() at
/home/bubut/Code/TalalAttendance/vendor/symfony/console/Application.php:827
Symfony\Component\Console\Application->doRunCommand() at
/home/bubut/Code/TalalAttendance/vendor/symfony/console/Application.php:191
Symfony\Component\Console\Application->doRun() at
/home/bubut/Code/TalalAttendance/vendor/symfony/console/Application.php:122
Symfony\Component\Console\Application->run() at
/home/bubut/Code/TalalAttendance/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:100
Illuminate\Foundation\Console\Kernel->handle() at
/home/bubut/Code/TalalAttendance/artisan:36
Laravel allows you to specify additional files to be compiled -- generally files that are used on every request in the application.
The file list is specified in /config/compile.php in the files array. If you have specified a file there but it does not exist (or the location is wrong) then artisan will throw that error when trying to compile it.
Same thing happened to me and removing the non-existent file from the list fixed my problem.
Same issue toady, and after debugging in Illuminate\Foundation\Console\OptimizeCommand, I found that some symfony components missing in vendor folder, even with composer install/update command for some reason.
Remove contents under vendor folder, then do composer update to see if missing components back. Or git clone whole project and composer update. Note that composer install will check composer.lock, if it existing and components missing there, issue triggered.
Note: For additional information
If your files are in a folder inside app folder, this is how you should list them.
'files' => [
'app/your_folder_name/file_a.php',
'app/your_folder_name/file_b.php',
'app/your_folder_name/file_c.php',
]
Hope this helps anyone who one to compile their custom functions.
Related
So, I have an API endpoint /api/v1/xxx that calls a single controller and method.
In the routes/api.php I have added the following logic
if (Auth::guard('api')->guest()) {
Route::post('xxx', 'API\v1\XXController#xx');
} else {
Route::post('xxx', 'API\v1\XXController#xx')->middleware('auth:api');
}
Everything works except when I run composer install, I get the following error:
a#b /var/www/html/test/app13 $ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
[LogicException]
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
Script php artisan optimize handling the post-install-cmd event returned with error code 1
Removing the lines in routes/api.php does not output that ^ error when I run composer install.
What am I doing wrong?
Thanks for any help.
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
This above lines says everything, you have laravel/passport installed and enabled but you forget to generate the key,
run command
php artisan passport:install
and it will work just fine.
I'm having trouble deploying my laravel app using envoyer, the error accuer in installing composer dependencies, here it is:
Generating autoload files
Illuminate\Foundation\ComposerScripts::postInstall
php artisan optimize
[RuntimeException]
No supported encrypter found. The cipher and / or key length are invalid.
it's my first time and I'm having lots of errors and don't really know how to fix them , I'd appreciate the help thanks
You need to generate key using command php artisan generate:key
As .env is not present in production so change app.php under config file to Something like below
'key' => env('APP_KEY','base64:42KCuY7E8Zc+JHrUZFyta4yspqLAjcVZeZVvymrjZBI=')
This would solve your problem.
I ran config:cache in my Laravel 5.2 application and this error started showing up.
Fatal error: Uncaught ReflectionException: Class log does not exist in F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php:738 Stack trace: #0 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(738): ReflectionClass->__construct('log') #1 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(633): Illuminate\Container\Container->build('log', Array) #2 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(697): Illuminate\Container\Container->make('log', Array) #3 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(853): Illuminate\Foundation\Application->make('log') #4 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(808): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter)) #5 F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php(7 in F:\xampp\htdocs\news5.2.23\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 738
I looked for many solutions. Nothing worked for me.
My .env file does not have any spaces
I deleted extra packages from my composer.json and ran composer update.
I ran php artisan clear compiled many times.
I looked for errors in my files but could not find any.
I also enabled the mysql extension since I found it somewhere. Then I did a fresh checkout of Laravel 5.2 and now the error is like this.
So, it's not a problem of any config file of mine. Its something else. Any of you have any idea?
Ok , so I solved it. Looks liek I had multiple issues.
In my fresh check out of laravel 5.2, where I was finding error about not having vendor/autoload.php file, I ran in the root directory in command window,
'composer update --no-scripts' , then 'composer update'. That solved the issue.
I also had to enable my mysql extension by editing php.ini file.
Finally, in my existing project, I actually found a problem in config/app.php. I missed a ',' somewhere. And people, laravel is a disgusting debugger. I miss my cakephp more.
It's a laravel 5 issue. Better to use laravel 4 still
Run this command:
php artisan dump-autoload
then composer update
I have recently cloned my bitbucket repo and I'm in the process of moving it to a new live directory.
Upon deploying my codebase to the new live directory, I got a "Class not found" error related to the thujohn/twitter package. So I attempted to remove the package altogether by using:
composer remove thujohn/twitter
Unfortunately, I get this error back:
PHP Fatal error: Class 'Thujohn\Twitter\TwitterServiceProvider' not found in /home/forge/hbavault.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 158
PHP Stack trace:
PHP 1. {main}() /home/forge/site.com/artisan:0
PHP 2. require_once() /home/forge/site.com/artisan:30
PHP 3. require() /home/forge/site.com/bootstrap/start.php:67
PHP 4. Illuminate\Foundation\ProviderRepository->load() /home/forge/site.com/vendor/laravel/framework/src/Illuminate/Foundation/start.php:210
PHP 5. Illuminate\Foundation\ProviderRepository->createProvider() /home/forge/site.com/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:82
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Thujohn\\Twitter\\TwitterServiceProvider' not found","file":"\/home\/forge\/site.com\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/ProviderRepository.php","line":158}}
I've removed reference to the package from my composer.json file and under providers and aliases in the config/app.php file
It is also removed from the two places I was using it in my code.
Any ideas as to what else I need to do to eliminate this error and entirely remove the package?
I'm having some trouble with artisan/packages.. I've added a package to my composer file and ran composer update and an error was returned:
PHP Warning: require(/home/xxx/public_html/bootstrap/autoload.php): failed to open stream: No such file or directory in /home/xxx/public_html/artisan on line 16
I can see that require path is incorrect, my structure is like so:
/home/xxx/bootstrap
/home/xxx/app
/home/xxx/vendor
/home/xxx/public_html
I hadn't changed any of the paths and everything seemed to work out of the box with this structure, basically removing the public folder and pushing everything up a directory.
I've opened up Artisan tried a couple of paths that kept failing so i've changed them to absolute:
require '/home/xxx/bootstrap/autoload.php';
It seemed to work from here on, but at the end of the process got another error:
Writing lock file
Generating autoload files
[RuntimeException]
Could not scan for classes inside "app/commands" which does not appear to be a file n or a folder
Rather than continue to mess it up i thought now would be a good time to clear it up, any ideas how to fix this?
Make sure you are using php 5.3 or higher.
Run php -v
Try creating an empty "app/commands" folder, fixed the issue for me!