ErrorException file_get_contents(C:\wamp64\www\casting\.env): failed to open stream: No such file or directory - laravel-8

I'm trying to run a laravel project on wampserver.
I have the following structure:
I executed the following commands :
composer update
composer install
php artisan cache:clear
php artisan config:clear
And when I run this Cmd: php artisan key:generate, I get the following error:
ErrorException
file_get_contents(C:\wamp64\www\casting\.env): failed to open stream: No such file or directory
at C:\wamp64\www\casting\vendor\laravel\framework\src\Illuminate\Foundation\Console\KeyGenerateCommand.php:96
I don't know what I should do.

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

Class "config" does not exist Laravel 9

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

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.

Vagrantfile for phpBB giving error about missing laravel homestead file

The phpBB Vagrant.md document doesn't tell you what to do to get started beyond downloading/cloning the Git repo to your local machine, then running vagrant up to start the VM. However, I am currently greeted with the following error when attempting to start up the VM.
λ vagrant up
Vagrant failed to initialize at a very early stage:
There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.
Path: C:/Users/Phillip/Desktop/phpbb/Vagrantfile
Line number: 0
Message: LoadError: cannot load such file -- C:/Users/Phillip/Desktop/phpbb/phpBB/vendor/laravel/homestead/scripts/homestead.rb
I am on Windows 10, have Ruby 2.5.1 installed, and Vagrant which all work currently. However, that directory in the project is currently missing. Do I need that file to get this all working, or should I just create my own Vagrantfile using the INSTALL.html docs and go that route?
You just need to install all of the dependencies with composer.
As written in the readme (https://github.com/phpbb/phpbb/tree/master):
To be able to run an installation from the repo (and not from a pre-built package) you need to run the following commands to install phpBB's dependencies.
cd phpBB
php ../composer.phar install
If you don't have Composer for Windows, you can just download and install the exe on the official page
After this you can run vagrant up from the primary folder and it should work.