How to fix artisan? php artisan optimize throws a [ReflectionException] - laravel-5

First of all, this is the actual error in git bash :
php artisan optimize
[ReflectionException]
Class hash does not exist
None of my artisan command are actually working. Earlier today, it was. Since i'm using git, I tried to find in the code I change what could be the error. No success.
I'm using Laravel 5.4.36
php -v : PHP 7.1.9-1+ubuntu16.04.1+deb.sury.org+1
vagrant -v : Vagrant 2.0.0
Homestead version is 6.2.2
Homestead is installed on windows 10.
There is the list of step I tried to solve the problem.
1.composer dump-autoload -> FAILED at php artisan optimize
2.composer update -> FAILED at php artisan optimize
3. Check if Hash is present in config\app.php
'providers' => [
/*
* Laravel Framework Service Providers...
*/
....
Illuminate\Hashing\HashServiceProvider::class,
....
'aliases' => [
....
'Hash' => Illuminate\Support\Facades\Hash::class,
....
3.1 I look if this file exist : Illuminate\Support\Facades\Hash It exist.
3.2 I look if this file exist : Illuminate\Hashing\BcryptHasher It exist.
4. I runned sudo chgrp -R www-data storage bootstrap/cache and sudo chmod -R ug+rwx storage bootstrap/cache.
I don't think that step (4) really did something that could help to solve this problem...
5. Tried composer dump-autoload again... Still FAILED at php artisan optimize
6. I deleted the vendor document then run composer install FAILED at php artisan optimize
7. I tried to run php artisan optimize in the file located localy on my windows and also into the file into the virtual machine. I know that both file are linked, but I wanted to see if there was a problem with one of the machine.
So, now I can't use php artisan <command> and I don't know what to do/try. Can you please help me fixing this! It will be appreciate!

It seems PHP is trying to inject a class hash but isn't able to resolve it. However, notice that the error describes the class name in lowercase. As you pointed out yourself, you probably need Laravel's well-known Hash facade.
Since PHP namespacing is case-sensitive, I suggest you check your Git commits to recent additions/modifications referencing the uncapitalized version of the facade.

Related

Laravel on VestaCP throws error 500. What file should I update to solve this problem?

When i try visiting my site I get this error, when I look domain.com.error.log:
PHP Fatal error: require(): Failed opening required '/home/<user/web/<domain>/public_html/../vendor/autoload.php
Files from my laravel project are placed into domain folder, files from public folder are inserted into /public_html folder. I've tried composer update, generate key, and all the other composer commands that people adviced here before.
I've set all my directories permissions to 777, so this error cannot be because of lacking permissions.
If you need any additional information, please ask, trying to solve this problem for 4 days already.
Edit: Solved this problem, it appeared because php didn't have access to files that are not inside public_html. So, this can be solved by either putting all your project into public_html folder, or updating your server rules to allow php access the folder with the project.
You need to install composer from www.getcomposer.org
composer dump-autoload
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
php artisan cache:clear
php artisan route:cache
php artisan view:clear
php artisan migrate --force

Laravel with php 7: No supported encrypter found

This question has been asked for many times, so let me list the steps I did on it:
Setting 'cipher' => 'AES-128-CBC', (original AES-256-CBC);
php artisan key:generate
pasting the new key to the .env file
but the error remains the same.
In phpinfo, mcrypt shows enabled, although there's no extension in httpd.conf. Some answers says that the extension is integrated with php 7.
The project is downloaded from git and installed with composer and npm, the .env file was sent from another developer.
Might be there is a problem with your mcrypt. You need to check whether mcrypt php extention is installed or not and it should be enabled.
on command prompt run php -m | grep mcrypt
if you couldn't find in your apache just install it.
https://www.myoddweb.com/2010/11/18/install-mcrypt-for-php-on-windows/ here is the link.
After performed last two steps from you listed into your problem, have you clear config cache?.
If not then you must run php artisan config:clear because Laravel caches all config data.
Also why you change cipher? if no reason, revert it with original and performed the steps again.
Might this work for you.

How to Uninstall Laravel?

I am facing fatal errors regarding Artisan. I think I couldn't install laravel complete due to slow internet. Now I want to remove Laravel from root and want to have fresh installation.
Can anyone help me?
if you have installed it globally you can simply remove it by composer global remove laravel/installer
If you have installed it via composer project you simply remove the directory.
Since I was looking all around how to uninstall packages and after reading tones
of documentations here's the short how-to uninstall a workbench package in Laravel
Remove package service provider from 'providers' array in app/config/app.php
Remove the package folder in workbench/
Run:
php composer.phar dump-autoload
php artisan clear-compiled
php artisan optimize
(optional) remove all related code using the package (you'll get errors about that)
or use composer global remove laravel/installer
For me, the command that actually did the trick was: composer global remove laravel/installer

laravel cache failed to open stream: No such file or directory framework/views

I use laravel 5.4. a clear cache after update config file. that appear like this error.
ErrorException in Filesystem.php line 111:
file_put_contents(/home/web_user/webhosts/mufer/backend.mufer.local/storage/framework/views/318a49f22562be3fc1c86c88ecc141c22e`8fed4e.php): failed to open stream: No such file or directory`
Then i try to fixed using following command:
php artisan route:cache
php artisan view:clear
php artisan config:cache
and:
file_put_content...fail to open stream:Permission denied in Laravel 5
Some answer are said craete /storage/framework sub folders and then composer update. but that also not working.
screen shot
Then i run composer dump-autoload
andcomposer update`.
But problem not solved..
Perhaps you are using Homestead?
I ran into this problem when using Homestead. Basically, when you are using Homestead and run the php artisan config:cache command out of your virtual machine, the cache paths get broken.
I solved it login via ssh to Homestead vagrant ssh and running php artisan config:cache from there.
My solution was to chmod /storage/framework/views directory to 777.
I had this same problem and my mistake was so simple it's hilarious.
I forgot to git add one of my files. So on the backend, it was trying to get this file.php but it didn't exist. It's usually quite descriptive in the error, except, I was running a job that jumps on a queue. All of a sudden, that helpful exception no longer exists :D
So in order to fix it, I had to:
git add -A
git commit -m "blah blah"
git push
On the server, I needed to:
git pull
composer dump-autoload
It's worked for me gently:
php artisan view:cache

Laravel 4 Class not found in bootstrap/compiled.php

I have created a new branch using Git, applied some updates to my code, checked out that branch on my staging server and I now can't run anything composer related.
I've added some new packages to composer.json which work on my development environment, but as soon as I try composer update on the staging environment I get class not found errors relating to the classes it's not yet downloaded.
I've tried
composer update
composer dump-autoload
php artisan clear-compiled
php artisan dump-autoload
php artisan optimize
But all result in the following error
PHP Fatal error: Class 'Artdarek\OAuth\OAuthServiceProvider' not found in
/var/www/sites/x/bootstrap/compiled.php on line 4321
Script php artisan clear-compiled handling the
pre-update-cmd event returned with an error
[RuntimeException]
Error Output: PHP Fatal error: Class 'Artdarek\OAuth\OAuthServiceProvider'
not found in /var/www/sites/x/bootstrap/compiled.php
on line 4321
What else can I try in order to get composer to download new files?
php artisan optimize --force
That command will re-generate /bootstrap/compiled.php
The --force arg is needed to re-generate the file when your environment is in debug mode.
I'm sure there is a more elegant way of dealing with this (and please accept any answer that provides that over this one) but this can probably be solved by deleting the entire vendor directory and running composer install again.
I know its not pretty but sometimes it's easier and quicker.
I had the exact same issue, which I solved by uploading the project again through filezilla to my server.
That doesn't solve the issues you are having with composer, however. Which begs the question: Assuming that you are working on a dedicated server, do you have composer installed globally in your server? If not you should still be able to do a php composer.phar update or just create an alias.
I might have misunderstood your question, and I realize that your question was asked a while back, but hopefully it will be helpful for someone else.

Resources