Laravel Artisan make command issue - laravel

I am trying to make a middleware using artisan php artisan make:middleware AuthorizedUserOnly but I get ErrorException like below.
file_get_contents(/mysite.com/www/local/composer.json) Failed to open stream no such file or directory.
This is my document root.
-local
-Laravel application folders
-artisan
-index.php
-composer.json
.htaccess
I changed my directory structure to work with shared hosting. And It was working fine.
KEY NOTES
Other artisan commands work. Like I tried php artisan route:list & php artisan config:cache & php artisan tinker.
This directory structure works fine.But as the error says that it is trying to find composer.json in local directory while it is on document root.
php artisan make:model command spits the same Exception
What could be the possible issue and solution ?

Solution : I moved my composer.json file to local directory and it worked fine. So new directory structure is
-local
-Laravel Application Folders
-composer.json
-artisan
-index.php
.htaccess
HOW ?
I am not sure about this yet. But this is the possible reason. php artisan make command create some files. So to included these created files into system execute composer dump-autoload. So to run composer it looks for in the same directory where artisan lives which is local directory in my case.
IMPORTANT
I changed laravel default directory structure to successfully run my applicaiton on SHARED HOSTING which laravel DOESNOT RECOMMEND.
We should follow the recommendations made by laravel to avoid any similiar issue. Specially never to mess with default directory structure at least.

Related

Please how can I undo ''php artisan livewire:make product-ratings''

After running the command I realized that I don't want to use it again so I deleted the two components it created which are
CLASS: app/Http/Livewire/ProductRatings.php
VIEW: resources/views/livewire/product-ratings.blade.php
Now when I try to access my product in the frontend I get this error
include(C:\xampp\htdocs\keyi\vendor\composer/../../app/Http/Livewire/ProductRatings.php): Failed to open stream: No such file or directory
2 possibilities
You have actually deleted it but it still thinks its there so do php artisan view:clear
or
It seems like you are trying to access a Livewire component that has been deleted, but your application is still trying to include it. This is causing the error message "include(C:\xampp\htdocs\keyi\vendor\composer/../../app/Http/Livewire/ProductRatings.php): Failed to open stream: No such file or directory".
To resolve this issue, you will need to remove any references to the deleted Livewire component from your code. This could include removing references to it in your routes, controllers, views, or other parts of your application.
Once you have removed all references to the deleted component, you should be able to access your product in the frontend without encountering the error message. If you continue to have trouble, you may want to check your logs or run your application in debug mode to get more information about the problem.
Did you try livewire:delete
php artisan livewire:delete product-ratings
and run
php artisan cache:clear
php artisan config:clear
composer dump-autoload # if needed
saw this command in the web livewire:remove.(Not sure if exist)
php artisan livewire:remove product-ratings

I uploaded a laravel 8 on my subdomain and i received error

i uploaded my laravel 8 project to my subdomain and i received this error
file_put_contents(E:\Projects\API\api-worforce\storage\framework/sessions/UkfntojT5Qzf99w9TR6Jvxs6iOBKlJ3TvLB6clTF): failed to open stream: No such file or directory
its still using local directory
Some of Laravel files are so-called cached. Therefore, the cache must be removed to fix this error as well.
How to fix the problem(two methods):
Method 1: Just go to the following path of your project in Laravel host and rename the config.php file to config_old.php or delete this file completely:
bootstrap / cache
Method 2: If the first method is not effective in solving the problem, run the following command this time:
php artisan config:clear
php artisan cache:clear
php artisan congif:cache

Changes not showing up when changing a file in laravel

I have a file in my resources/lang folder and when I made a change to it, it didn't show up on my site.
I've tried php artisan cache:clear, php artisan config:clear, php artisan view:clear, but still no change
Try to clear views folder in Project/storage/framework. It might be an issue.
Have you tried your site on another browser ?

token mismatch error in laravel backpack

hi there is problem with me I had made complete admin panel using laravel backpack. after uploading on domain its creating the problem when adding deleting or editing operation performs. Error is token mismatching in backpack crud system. please tell the problem with my project
I think you have issue with storage folder permission check this out Laravel Installation Docs
Directory Permissions
After installing Laravel, you may need to configure some permissions.
Directories within the storage and the bootstrap/cache directories
should be writable by your web server or Laravel will not run. If you
are using the Homestead virtual machine, these permissions should
already be set.
Another possible issue is that your variables in .env are not correct
APP_URL=http://localhost //Change this to your url
APP_ENV=local //Change this to production
After you check these things you can do this
Delete all files in app/storage/ files : cache/, sessions/, and views/
Or you can do it by using this commands if you have SSH access to the server
php artisan cache:clear
php artisan view:clear
php artisan route:clear

moving Laravel project between computers

I have been working on a laravel5 project on a computer , but now I want to continue on an other, but don't know how :(
I'm using wampserver and the project is in the "www" folder, this is the error I'm getting when trying to open the project: " Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request"
Your error message is very vague, so it is hard to pinpoint the cause. I assume you just copy pasted all of the project files
Try these steps:
Make sure you copy all of the project files including the hidden ones(.env).
Prepare your destination computer as in http://laravel.com/docs/
Check you have all the necessary PHP extensions available in php.ini as in above link requirements. Also, watch your PHP version!
Install composer https://getcomposer.org/doc/00-intro.md
When copied, go to your destination folder and run composer install.
Run php artisan key:generate from the command line.
Run php artisan cache:clear from command line
http://php.net/manual/en/install.windows.commandline.php
Make sure your webserver is serving pages from project/public folder.
If laravel is failing, check the log file to see the cause
your_project/storage/logs/laravel.log
Copy the project folder and navigate terminal/cmd
just run following commands.
Create database and place the same name at .env file in laravel project folder
1. composer install
2. php artisan key:generate
3. php artisan cache:clear
4. php artisan migrate
UPDATE: If you're getting
Whoops, looks like something went wrong
in app/config/app.php, set debugging as true with:
'debug' => env('APP_DEBUG', true)'
If you're getting the error
No supported encrypter found. The cipher and/or key length are invalid
for some people it worked to do cp .env.example .env before (2).
You would also have to create new storage link, because Laravel uses absolute path inside it.
php artisan storage:link
https://stackoverflow.com/a/32722141/3982831 Please follow this to resolve your problems. All people forget about permissions on folders.
After you have done as Ademord answer, you might need to use refresh to your WAMP, XAMP or any other development stack you are using. I had the same issue plus changes were not reflecting in the front end. For example new routes in the web.php were not updating.

Resources