Best place to create a cache folder in a Laravel 5.1 environment for third party libraries to write - laravel

I am facing the following issue in the production server (not in local or dev):
production.ERROR: phpFastCache\Exceptions\phpFastCacheDriverException: PLEASE CREATE OR CHMOD /var/www/curator5/vendor/raiym/instagram-php-scraper/src/InstagramScraper/sessions/curatorlive.com/Files - 0777 OR ANY WRITABLE PERMISSION! in /var/www/curator5/vendor/phpfastcache/phpfastcache/src/phpFastCache/Core/PathSeekerTrait.php:110
On the following discussion: https://github.com/PHPSocialNetwork/phpfastcache/issues/441, they suggest to create a folder with absolute path for that library to write to. I was thinking to create a folder in storage/app called cache for that purpose, I know that in storage/framework/cache there is a similar folder for the framework to cache, I am not sure if I should use this folder instead.
My questions:
Where in the Laravel 5.1 directory structure is the best place to
create this folder?
Should I use the storage/framework/cache or
create a new one if so what is the best place to create it?
Reference to the folder cache I would like to create inside storage/app and the stuff the library will create inside that folder, in the following image:
Image

Related

Ability to store assets outside of the website in cheaper storage

I am trying to understand if there is a possibility to store assets outside of the folder structure of the website (outside the scope of codeigniter).
My current infrastructure is using CodeIgniter-2 with PHP 7.1 on a IIS Windows platform.
Yes you can simply create a folder at the root of your installation (at the same level as the index.php file) and store whatever you want inside
You can also use .htaccess to protect access to this folder from http and from outside
cordially
If what you want is to access assets stores in a S3 instance you can use their SDK provided for PHP:
https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-examples.html
There's even a few libraries on packagist that you can use for this:
https://packagist.org/packages/aws/aws-sdk-php
With a library like this, you can both access and send files to a S3 instance.
If what you want is to access files in another folder outside the scope of your codeigniter 2 in a windows platform you'll need to setup a mklink inside your codeigniter folder.
This will create what is called a symbolic link to the desired folder.
You can read more about that here: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mklink
The syntax would be something like:
mklink [[/d] | [/h] | [/j]] <link> <target>

How to change storage path in laravel to resources/views?

In Laravel 5.5, if I upload a file from a form, it will be stored in own storage directory.
Now I want to change it and want to upload file to this path: resources/views/layouts
I think easiest solution would be:
create directory in storage directory with unique name, like layouts or so
create symlink from /storage/layouts to /resources/views/layouts
save all files you want to /storage/layouts and they will appear in /resources/views/layouts
by creating symlink I mean linux feature (https://en.wikipedia.org/wiki/Symbolic_link#POSIX_and_Unix-like_operating_systems)

Storing images in storage folder of laravel, and fetching it by a http request is not working

I have deployed laravel application in heroku. I am storing images in storage folder of laravel and trying to fetch it by defining a route. It was working well on local, but when i trying to do the same on server, then its not showing the images. I thought that storage folder is inside the laravel, so it should work fine, but its not working.
Can i store images in public folder by creating a named folder "gallery" inside that and put that gallery folder in gitignore. so will the gitignore folder be vanished when i will push the laravel project again?
Other options are using another file system. Most of them are paid, so i was thinking to save the images in database, is that the good idea or i should move to files only.
First of all, the storage directory should have right permission.
You should create a symbolic link from public/storage to storage/app/public.
Create the symbolic link:
php artisan storage:link
You cannot save images in database, only their names or links etc. I implemented the same thing you did by naming the files to their path and storing that to the database and then using it to fetch the data from folder on sever

how to include or extends a language file in laravel vendor folder

I'm trying to load a language folder inside a laravel's package called permissionmanager , I know that including files directly inside vendor folder isn't the recommended way, but trying to extend it on the resources/views/vendor folder was unsuccessful.
the problem occurs when i try to upload the folder to the server using filezilla,it's not allowed. because i suppose laravel's vendor folder is protected.
so how can I load that lang file (es/permissionmanager.php) in the right way?
Use the "resources/lang" folder, not "resources/views". So it will be:
resources/lang/vendor/backpack/es/permissionmanager.php

Does Laravel have a convention for a local permanent uploaded file storage location?

I have some forms that allow the user to upload files that only they can view so I will have to store them somewhere. However, I haven't been able to find any information about where these files would usually be stored if I want them to be kept on the local server. Therefore I have to assume that there is no convention for the permanent storage location of uploaded files. Am I correct in this assumption?
To be clear, I'm not talking about temporary storage locations.
Additionally, would it be a bad idea to have the storage location of all the files as a subfolder of the app directory (with gitignore enabled on it)? Or would it be a better idea to have it outside of the app folder? Thanks!
There is no explicit convention on where to store user uploaded files.
However Laravel ships with a storage directory where it stores framework related data such as cache, sessions, etc. As the name denotes it's a good place to store files, not just framework files. Also the Laravel Filesystem Documentation mentions that the default configured location is storage/app (but that can be changed to fit your needs):
When using the local driver, note that all file operations are relative to the root directory defined in your configuration file. By default, this value is set to the storage/app directory. Therefore, the following method would store a file in storage/app/file.txt: Storage::disk('local')->put('file.txt', 'Contents');
This storage/app folder will by default be ignored by Git.
If you also need the files to be publicly available, then you have two options:
1. Store them somewhere in the public directory.
2. Store them in the storage directory as suggested above and create a symbolic link to the folder from a public location. On Linux you can run this:
ln -s /path/to/laravel/public/files /path/to/laravel/storage/app/files
Of course the directory names can be whatever you like, I used files as an example.
The first option is for cases where you don't have shell access or are otherwise unable to create symbolic links. So if possible I suggest you use the second option.
Laravel uploads to the temporary file path, then you will have to move the file:
$request->file('photo')->move($destinationPath);
This method will move the file from its temporary upload location (as determined by your PHP configuration) to a more permanent destination of your choosing.
SOURCE: https://laravel.com/docs/master/requests#files

Resources