Laravel File Storage Location Confusion - laravel

I am struggling to wrap my head around the file storage in laravel. I setup the php artisan storage:link like it said to do online.
Then to store my images in my store method
$request->file('brandimage')->storeAs('/public/brandimages', $filename);
I tried doing it without the /public but it throws an error. This means when I want to delete the files I have to use
Storage::delete('public/' . $brand->brand_image_path);
(The brand_image_path is: thumbimages/thumb-post-5.jpg so it isnt adding any extra directories.
My issue is when transfer my site from local to my server none of my images show up. My project is looking for them at www.sitename.com/thumbimages/thumb-post-5.jpg but in order to actually see them I have to go to www.sitename.com/storage/thumbimages/thumb-post-5.jpg"
I'm guessing that it should work the same local as it does on the server so what part am I doing wrong?

I discovered that I should be using /storage/thumbimages/thumb-post-5.jpg" even when I am on local. /storage and not using /storage both work on local.

Related

Install Laravel on Sub Domain has Http 500 error

Having some real problems installing a Laravel App on a Bluehost[ed] subdomain. I get a 500 error and checked a number of web-resources and tutorials.
Here's what I've tried:
A) A simple FTP of the MyGreatApp to the main domain root, copying the MyGreatApp public folder in the public_html/subDomainName/ as suggested by "Deploy Laravel To Shared Hosting The Easy Way" (but with sub domain thoughts) https://www.youtube.com/watch?v=6g8G3YQtQt4
But I get a http 500 error.
B) A similar method using SSH and cloning a git repository which contains the Laravel boiler plate.
In each case the boilerplate Laravel app doesn't run. I can echo out of the index.php to let me know what I get to in the PHP.
Many tutorials suggest changing the paths (for subdomains) in the index.php file too as the public folder of the subdomain is buried differently to the public_html of the main domain.
We are using PHP 7.1 on bluehost and Laravel 7
Any thoughts to get a stage beyond the 500 error?
EDIT: The error is thrown after attempting to execute this part of the code...
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
Delete everything (backup the important files, I'm not responsible for any data loss)
Create folder laravelapp or whatever you want
Upload your laravel project to that folder
Create new subdomain and point to public_html/laravelapp/public
We figured it out. It related to a problem with the dev PHP environment and the prod. PHP environment. PHP(Dev) > PHP(Prod) and a version issue in Symfony. When we downgraded Symfony to the "right" level of PHP it's fine.

How to load schema.graphql in laravel graphql-playground without using public folder and php artisan

I am developing a graphql based laravel app and using Lighthouse for the purpose.
Now I have to access the playground through localhost/blog/graphql-playground (without using artisan or writing public every time), for this purpose I have copied content of 'public' folder to the index folder. Every controller including graphql-playground seems to work but playground cannot fetch schema.graphql placed in root directorie's graphql folder (localhost/blog/graphql) with error 'Server cannot be reached'. but if I give URL localhost/blog/public/graphql it will work. I have went through all the possible files and couldn't file settings to be changed. I tried deleting content of public folder. after that even /public wouldn't work.
How do I fix this?
see image
I think that your artisan server is running on port 8000. So try with http://localhost:8000/graphql.

Laravel 4 - can't access images in public folder

I have a strange behaviour from Laravel. I just copied the website to a new hoster. Everything is working quite fine but one thing: I can't access the images in my public folder. If I try to open an image on my own with "domain.com/img/Ausfahrten/42.png i get the following error:
error image loading
The folder structure on my server looks like this:
enter image description here
What method can't laravel find and how can I resolve this? I've already checked file permissions on the server, everything's fine there.
Laravel throw that error when it cannot find the file. Try to access to another directory without Uppercase letter in its path name.

Laravel ClassLoader trying to load an old version of my model

So a while back I decided to redo one of my models in Laravel completely, but I wanted to hold on to the original copy of the file just in case. So I renamed it to something like MyModel (OLD).php and left it there in the models folder next to the new model.
Now that I understand Laravel a bit better, I realize that wasn't a great idea, but in any case everything seemed to work for months. Then today, I made a minor update (modifying a database query) to one of the functions in my new model and suddenly Laravel is trying to load the old copy of my model. I finally moved the old copy out of the models folder and into a backup folder completely outside of my laravel application, but now Laravel throws the error:
include(pathToMyModels/MyModel (OLD).php): failed to open stream: No such file or directory
referring to this section of ClassLoader.php
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}
I tried undoing the modification to the model, changing the route and controller function name, clearing laravel's cache, clearing the browser cache, using different browsers, but nothing seems to work except to manually include the model's php file before calling the class it contains. What can I do to get Laravel to automatically recognize my model like it does all the others I have?
Try to clear composer cache and then run composer dump-autoload.
composer clear-cache
composer dump-autoload
if you don't want to run commands then try this one, i think it's solve your problem.
goto your laravel_project_folder\vendor\composer
now open the file autoload_classmap.php and autoload_static.php in your text editor
and find your old/backup file name line
and rename with actual filename and correct their path.
now run your project again and check for the error occurance, i think your problem is solved.
i just knew that my laravel using old controller after 1 hour of debuging. what time waste
i tried accepted answer but still persist
i delete the controller and recreate, now works
copy all the code
delete the controller
make http request to that controller (404)
create file same name
paste in

moving modx to new server - clear cache

I moved website to new server, domain stay the same, files structure stay the same, but path to public_html has beed changed. Database has been also moved.
I tried to clean cache, but i dont think I made it. This is error i get:
Could not find action file at: /home/account_name/domains/domain.co.uk/public_html/manager/controllers/default/welcome.php
account_name is different now.
I havent access to the old server, so I cant login and clear cache. I tried to do it using php script I found, but it didnt help.
Moving to new server documentation - there is welcome.php error and how to fix it, but since I haven't access to website from old server, I can't do it.
Also I can't login and clear cache in admin panel, because this message in when i wan get access to it.
I also change in db, in modx_workspaces->path from {core_path} to home/account_name/domains/domain.co.uk/publis_html/core, but didn't help.
How can i clear cache or if it's not the case, what should I do to make it work?
Update
I have change location in settings:
config.core.php
connectors/config.core.php
core/config/config.inc.php
manager/config.core.php
In .htaccess I couldn't find path to website, I didn't change anything.
I remove all content from core/cache/, except one file (.gitignore), and if I go to domain.co.uk/manager/ it's blank page, no content at all. And still can't log in.
Clear the cache on the new server manually VIA FTP or from a shell.
Change that modx_workspaces thing back
did you change all your settings in core/config/config.inc.php ?? if not do so, that is where you will set most of your paths & database credentials.
you have a backup? good!
Now upgrade to the same version of modx, that should fix all your path issues. [make sure you are not logged into the manager while trying to upgrade]
When moving the site to the new server rather watch two things:
the right paths into this files
/config.core.php
/core/config/config.inc.php
/connectors/config.core.php
/manager/config.core.php
the folder /core/cache/ is empty. They can be cleaned simply by removing the contents via ftp.
and correct the value in the database back to {core_path}

Resources