I have an application on Laravel 4.2. Currently, when I see the http requests sent from my application, the cookies are all stored in the root directory as path=/. I would like to store the cookies in a custom directory like another folder inside the storage directory.
Go to config/session.php,
set
'path' => other directory path (route path)
Related
I'm having a problem loading images in my html dynamically after storing them successfully with Laravel Vapor.
I have followed this documentation provided by laravel vapor to store files, and it works like a charm. I copy my uploaded files from the tmp directory into the root of my S3 bucket and then store the path of that file in my databases images table so that later I can return the file path to my front end and display the image in my browser.
Unfortunately this is always returning a 403 status code from AWS S3.
I could fix this by making my generated S3 bucket public, but that would raise a security issue. I believe this should work out of the box, not sure where I could have gone wrong... any ideas?
I am returning the uploaded image url using the Storage facade.
use Illuminate\Support\Facades\Storage;
return Storage::url($image->path);
Where $image->path is the file path in my S3 bucket.
I'm sure that the storage facade is working correctly because it is returning the correct url with the file's path.
I got the solution to this problem. I contacted laravel vapor support and I was told to set the visibility property for my file to public when I copy it to the permanent location, as stated in Laravel's official documentation here.
So after you upload your file using the js vapor.store method you should copy it to a permanent directory, then set it's visibility to public.
Storage::copy($request->path, str_replace('tmp/', '', $request->path));
Storage::setVisibility(str_replace('tmp/', '', $request->path), 'public');
I also noticed that your can set the visibility of the file directly in the vapor.store method by passing a visibility attribute with the respective value.
vapor.store(file, { visibility: 'public-read' });
As a side note: just 'public' will return a 400 bad request, it must be set to 'public-read'.
I have a Larevel-app in a shared hosting. For the setup, I had to create a new folder in the main carpet of the hosting and copy the content of my public folder to public_html. I made changes in index.php and all working fine and nice. However, when a user upload a file that needs to be public, this file it saved in the myproject/storage/app/public path but not reflected in the public_html/storage so I can't access to it.
Reading the documentation, I know it is a problem with the symbolic link.
how can I change it?
Note: I can't access to the cdm because it is a shared hosting without access. It is window hosting.
make this route in web.php then hit this
Route::get('/artisan/storage', function() {
$command = 'storage:link';
$result = Artisan::call($command);
return Artisan::output();
})
I'm trying use laravel mix but in browser return error 404
Laravel 5.6.4
My .env APP_URL
APP_URL=http://localhost/base-site-template/public
My mix-manifest.json
{"/js/lib/echarts.js": "/js/lib/echarts.js?id=a24928e50f4d775d9e3e",
"/js/lib/moment.js": "/js/lib/moment.js?id=a3cde5d62118f1b1ac08",
"/js/lib/axios.js": "/js/lib/axios.js?id=1129cee8012a0ec7cb58",
"/css/lib/vuetify.css": "/css/lib/vuetify.css?id=c7533b5bc8f96cca4e90",
"/css/index.css": "/css/index.css?id=d41d8cd98f00b204e980",
"/css/template.css": "/css/template.css?id=c7533b5bc8f96cca4e90",
"/js/template.js": "/js/template.js?id=3213a53c38fb71543141",
"/js/lib/vue.js": "/js/lib/vue.js?id=e41f4d0b6a918ca9213d",
"/js/lib/lodash.js": "/js/lib/lodash.js?id=98dc43a5e921b41ef214",
"/js/lib/vee-validate.js": "/js/lib/vee-validate.js?id=bfc8600a0fc91c459f0e",
"/js/lib/vuetify.js": "/js/lib/vuetify.js?id=f0c3ad550b36770ee4c9",
"/js/index.js": "/js/index.js?id=5a79665b4d1331d942d7"}
I'm trying to get css and js files using {{ mix('js/template.js') }}
Can someone help me?
Your resources are trying to be loaded from the root directory:
You're accessing the site at /base-site-template/public not /. So you'd have to access the files at /base-site-template/public/js/index.js not /js/index.js.
If you have your APP_URL set properly, you can use the asset() helper to prefix your APP_URL.
{{ asset(mix('js/template.js')) }}
Assets are placed into the public/ directory when they're compiled, e.g:
public/js/lib/echarts.js
Your browser will treat relative requests beginning with / as relative to the base path which is http://localhost/. For example when you load the page http://localhost/base-site-template/public and it references /js/lib/echarts.js the browser will make this request:
http://localhost/js/lib/echarts.js
However that is not where your assets reside, your assets reside in:
http://localhost/base-site-template/public/js/lib/echarts.js
Therefore you will need to either:
Reference the assets using an absolute URL instead of a relative path
Tell clients browsers to use a different base path
Move your application to the base path
You can reference the assets with an absolute path using the asset helper:
asset(mix('public/js/lib/echarts.js'));
You can tell the client browser to use a different base path using the base element in your documents head:
<base href="http://localhost/base-site-template/public/">
In CodeIgniter HMVC, I want to access a model of user modules from the root directory.Actually, i want to access database, model and all the things.
Just manage a config item in config.php.That is application/config/config.php add a config item like this..
$config['modules_locations'] = array(
'modules/' => '../../modules/' //referencing at your root having modules folder
);
Note: It is not necessary that your folder must named as modules .You can named it as my_modules etc..
Then create a folder modules in root folder and access every thing like you do in application folder.
Hope it works great.
So i have an API created with Lumen with some documentation done with Apidoc outside of the public folder and i'd like to serve it when the user goes to the URL http://apidomain.com/docs
This is the structure of the app
ProjectRoot
->API
->Auth
->Docs
->v1
->app
->bootstrap
->database
->public
...
Is there any way to create a route that sends the user to API/Docs?
It's done, it was actually my bad, when trying to call the file via routes it actually messed up the filepath for the other files. So when i looked in the dev tools on chrome i noticed i was getting 404's on my js and css files, hence the failure to load the ApiDoc