In my local server launched with artisan serve need to specify the path to save the files to / public + path to the directory to save. In my real server as points directly to public is not necessary. Anyone know how to fix this to not having to change routes every time I'm in the local environment?
I always use URL::to('asset path') for links, and base_path() for server folders, and it seems to work for me.
An example I just dug up from my own app:
$file->move(base_path()."/public/uploads/".$type.'/', $filename);
Related
I develop a Laravel Api in local it's work, when I deploy I have a error 500.
I copied the folder to the server.
I moved the public folder to root and changed the path in index.php.
I modify the file .env with the prod value.
With I test with postman my route https://my-domain/public/api/v1/mytest : I have a error 500.
What did i miss ?
Please be sure you have followed all the steps. I assume you do not use a subdomain.
Move your zipped project to a folder in the server (e.x. /home/mollusk/project)
Unzip the project
After unzipping your project, move everything under public folder into public_html folder (e.x. /home/mollusk/public_html)
Edit index.php under public_html folder changing
$app = require __DIR__.'/../bootstrap/app.php';
to
$app = require __DIR__.'/../project/bootstrap/app.php';
Give your domain name as value to APP_URL variable in .env file
APP_URL=https://my-domain
I resolve this problem.
The version lumen in dev and prod was different. I upgraded the dev version (5.8) to be in phase with the server (8.x) and it's work !
I have an existing laravel project that I wrote on a Windows PC, I tried to copy the project to a MacBook and it runs well, but the problem is the storage:link doesn't work, all the picture I save in the storage folder can't be accessed through the app, I tried to enter the link of the files manually on the browser and it's still doesn't work.
I also checked the folder and the files, they still exist.
I'm still new in using Mac, does anyone have a solution?
I also tried to upload my laravel project to a shared hosting without SSH access, how can I make a storage link?
Thanks in advance.
I am not sure, maybe this is for wrong file locations. well, if you can find the folders you want to link you can run a raw command anyway
ln -s /project_folder/storage/app/public /project_folder/public/storage
Once you move the project to another system or directory , you need to recreate the symlink. Re run the command
php artisan storage:link
I'm using a shared hosting service and move everything in laravel's public directory into hosting's public_html and move everything beside laravel's public directory into a new folder I generate in the same directory as the public_html directory such as below:
root / parent directory
public_html
laravel
Make a file in public folder named symlink.php which contains this code:
<?php
$targetFolder = '../laravel/storage/app/public';
$linkFolder = $_SERVER['DOCUMENT_ROOT'].'/storage';
if(symlink($targetFolder,$linkFolder)){
echo 'Symlink completed';
} else {
echo 'Symlink Failed';
}
?>
you can specify the $targetFolder variable to your storage/app/public path like above.
afterwards call the file through your laravel link.
eg:
http://mylaravel-example.com/symlink.php
nb : the file's name is not a fixity, you can specify it as you desired.
I am running laravel on xampp and I have problem with accessing pages,
http://localhost/laravel/public/ I get a login page which is good
however when I go for example http://localhost/laravel/public/smokeyard
I get 404 error with The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
Route:
Route::get('smokeyard', 'GuzzleController#smokeyard');
Controller:
function smokeyard(){
return view('smokeyard');
}
All my views are located in resources folder.
if you want to access laravel project without running artisan serve, you need to change few settings,
copy the .htaccess file from the public folder and paste it in the root folder of your application
rename the server.php in the root directory to index.php
now go to localhost/your_project_name/smokeyard for the url you want to check
hope this helps
Run php artisan serve and access your server at http://localhost:8000. Your routes should work fine then.
You can't access your laravel application routes straight away through the folder structure with xampp. You need to setup the web root to point to the public folder and access localhost or run the laravel server and use it. This is because the url rewriting would fail when you access the routes in laravel the way you do.
I tried this in MX Linux 21.xx. My xampp got messed up after installing larvel on it.
check MySQL status with command
mysql service status
stop the service using the command
service mysql stop
you will be prompted to provide your password, Enter password.
start xampp using command
sudo /opt/lampp/lampp start
All should be back to normal
So I am having an issue with pushing a Laravel app to production on a dedicated server's subfolder.
Server is run on Apache.
Url I want to push my app would be subdomain.domain.com/project
The structure of my dedicated server is
.cpanel
...
-laravel
-app
-vendor
-...
-public_ftp
-public_html
-folder
-contents of laravels public directory
-ssl
I know that in order not to expose my hidden files I am required to install it in a root directory, but this is not an option because I will be having multiple projects running under subdomain.domain.com/project-1, subdomain.domain.com/project-2 and etc... and all will have a separate laravel installation.
I need a hand in order to achieve that, can anyone give me some advice?
Managed to do it myself, the problem was when i was creating a symlink, so instead i just moved contents of my public directory to public_html/project-1/ and changed index.php path to /../../laravel/
The thing was that I have done it originally but I didnt expect that permissions for storage need to be manually set, that solved my issue and laravel works.
ALWAYS CHECK ERROR LOGS :)
You can place your separate folders in your subdomain with no problem.
The important thing is that you need to point the browser to public/ folder under your laravel projects.
You can create a .htaccess file with the command below in root folder of each project and perform a redirect.
Place the following command in your .htaccess file:
RedirectMatch ^/$ /public/
I have created a laravel 5.0 project with php artisan serve, now i need to know how to run laravel 5.0 project run without start php artisan serve, i have already browse lot of websites no one help me..
You need to change "server.php" to "index.php" then copy ".htaccess" from public to root directory.
See: https://stackoverflow.com/a/30053989/3948755
Laravel sever Folder is "public". There is an index.php so you can run you project from there.
Suppose if you using UbuntuOS then you have to create your local server in public directory. Suppose your folder name is laravel_test then go in that directory and run some thing like this
php -S localhost:8000 -t public
If you using windows then access public folder from URL.
localhost/laravel/public
Actually it's bad practise to access folder from URL but for local its good. You also can go with host entry. Just make sure that your target folder is "public" directory.
Normally you would have WAMP/XAMPP installed. You can access Laravel project like below
localhost/laravel/public
But this is not recommended. You should create Virtual host for example
laravel.local that pints to server-root/laravel/public.
this is how you create virtual host.
Or even better go for a Laravel Homestead .
How is your .htaccess file configured?
Try with localhost/laravel/public/index.php
Use http://localhost/projectName/public
It will be work. but in case if you have another Route and you can not access that Route and get the error like " Page Not Found " then please use the following command
sudo a2enmod rewrite
Now open the http://localhost/projectName/public/yourRoute
This is a little late but still applicable, what I like to do (using ubuntu 14.x+) is put my laravel project (let's say Project1) in my var directory, so it would be in /var/Project1, then symlink the public folder to somewhere in /var/www(+/html depending on apache version).
Symlink can be done something like this:
ln -s /var/Project1/public /var/www/html
This keeps your internal files off the grid so to speak, this is untested so if I've missed anything just comment and I will amend this post.
EDIT:
Obviously if your http root is /var/www/html you can put your project in /var/www/Project1
If you have access to xampp or wampp on your operating system you can more or less configure your virtual host like in the instruction below:
https://bestin-it.com/creating-virtualhost-on-your-local-computer-to-start-simple-index-php/
This instruction shows how to run it locally on your PC, but it works generally the same on any hosting portals. In most case in payed portals you have any web panels to configure your public folder that reference to /public folder in laravel folder's structure.