Class "config" does not exist Laravel 9 - config

I have a Laravel 9 project which works fine on local, but after uploading it to the online server I get this error :
Fatal error: Uncaught ReflectionException: Class "config" does not exist in /.../vendor/laravel/framework/src/Illuminate/Container/Container.php:875 Stack trace: #0
This project is not in the root folder but inside another folder, because I have multiple laravel projects. The other one laravel 8.8 is working fine.
That's what I've tried so far:
delete vender folder and install again
delete files in cache folder
run command $ php artisan optimize:clear
run these commands :
composer install
composer dump-autoload
php artisan cache:clear
php artisan config:clear
nothing wrong with my .env file, I just left the default of Laravel

I solved this issue.
I had some missing php extensions on the server. Installing them solved the issue.
Check the Laravel 9 System Requirements here in their doc.
run this code on your server to see your installed extensions and install everything that is missing.
<?php
echo "<pre>";
print_r(get_loaded_extensions());
echo "<pre/>";

Remove all the content of bootstrap/cache first:
cd bootstrap/cache/
rm -rf *.php
Then run:
cd ../../
composer dump-autoload

Related

Laravel 9 - Install Breeze

I have created a Fresh Laravel-9 Project, created a database in admin-sql and updated the .env file. After this, I ran following commands:
composer require laravel/breeze --dev
php artisan breeze:install
php artisan migrate
npm install
npm run dev
I then ran Laravel and registered a user. I then closed my project and closed all command prompt windows. Next time I ran my project and trid to login and got the following error
Did you forget to run npm install && npm run dev?".
I then ran npm run dev and a server started at 127.0.0.1 and then I was able to login.
My question is, everytime I open my project, do I have to run an additional server at 127.0.0.1 using npm run dev in addition to php artisan serve or am I doing something wrong?
When I used Laravel 9 for the first time, I had the same doubt.
It seems you do need to run it everytime.
But if you do not want to build your files again then you may use the build command
npm run build

Laravel-permission Undefined type PermissionRegistrar

I'm trying to install the package Laravel-permission v5 for a project in Laravel 8.
Following the instructions at the documentation, I runned
composer require spatie/laravel-permission
and to be able to migrate the permission tables I executed:
php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
Instantly, in the file database/migrations/create_permission_tables.php it gives me the error
Undefined type 'Spatie\Permission\PermissionRegistrar
What can I do? I'm new in Laravel
Did you import it in config/app.php ??
Try this:
php artisan optimize:clear
# or
php artisan config:clear
php artisan migrate

Laravel 8 fresh installation livewire directory does not exist

I have a fresh installation of laravel 8 and I have also installed livewire but when I register I get the error
The "C:\xampp\htdocs\sms\app/Http/Livewire" directory does not exist. (View:
C:\xampp\htdocs\sms\resources\views\layouts\app.blade.php) (View:
C:\xampp\htdocs\sms\resources\views\layouts\app.blade.php)
I followed the instructions in the laravel documentation page.
What could I be doing wrong?
I guess you did run the third command php artisan jetstream:install inertia too, that could have removed livewire, Try rerunning the second command php artisan jetstream:install livewire to install livewire then run npm install followed by npm run dev
Create a new livewire component to generate those directories. Reinstalling did not create them for me.
php artisan make:livewire counter
If you haven't started anything yet, just re-install laravel and run the command php artisan jetstream:install inertia cause there's an error when reverting back from livewire to inertia.

apidocjs not returning anything in response

I have installed 'apidoc' after installing 'npm' and 'node' for my API documentation by the help of following command:
npm install apidoc -g
After installing apidoc globally, I simply ran below command on my project directory (assuming apidoc will consider its default template file):
apidoc
In result no errors and no documentation generated.
Similarly, I have tried:
apidoc -i ~/PROJECTS/jruby/project/webservice/ -o ~/PROJECTS/apidocs/apidoc/ -t ~/PROJECTS/apidocs/mytemplate/
But nothing happens, in that case I had nothing on 'mytemplate' directory.
Can you guys please tell me what I've missed to install/consider? and why nothing is appearing on command execution?
Note: I'm using this for my ruby application, but unable to install its gem as we're running our application on ruby 1.9 and it requires ruby 2.0. I need an independent solution that should works for other projects as well.
Thank you.
I got the solution; copied 'package.json' file from https://github.com/apidoc/apidoc and ran below command for npm
npm install
after getting success install nodejs properly by following steps:
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
then went to the project directory and ran the following command:
apidoc
after success of above command got html document in doc/ directory inside project. Cheers !

How do i run 'composer' command via SSH?

I want to reload my project's custom classes in Laravel so they become accessible, but on a shared hosting enviroment. To my understanding, so far, locally, I've been achieving the desired by using this command:
composer dump-autoload
however, running that via putty's SSH gives me:
-bash: composer: command not found
Any idea?
please try:
php composer.phar dump-autoload
Because composer is only avaialble when installed globally, into /usr/local/bin/composer path.
Hope that helps!
You have to install composer on the remote machine that your are ssh'ing to. You can find installation instructions on the composer homepage.
Try this command: # php-cli composer.phar --help
In some servers Composer should be invoked via the CLI
Try:
php composer.phar dump-autoload
or
php composer.phar update
In webfaction is: php54 composer.phar dump-autoload
If you are running in a production environment make sure to run:
[path to composer.phar] dump-autoload --optimize
This will autoload ony the necessary classes and GREATLY increase performance of your Laravel app.
If you are working with shared hosting, you probably need to put the full path to your composer executable. So it was in my case. Following the recommendations in this answer SSH Shell commands not found (composer, npm), I managed to run composer from the bash script:
which composer // In remote machine manually
This command shows the path where composer is installed on the remote server. You can also see the path by doing:
echo $PATH // you can surely add it
If composer is not on the $PATH, You can add it, if shared hosting gives you enough privileges, or you can just run the command in your bash script by calling composer with the full path. In my case it was to run:
$/opt/cpanel/composer/bin/composer install