Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel move project from Ubuntu Server to Local XAMPP

I have a Laravel project that I copied from my Ubuntu server and now I am trying to run it my local machine (XAMPP on Mac) I have been struggling with this for a few days now and I feel like I am going insane.

When I paste my project in XAMPP htdocs folder I get this error:

View [welcome] not found

Which php artisan cache:clear makes that go away, then I get this error:

The bootstrap/cache directory must be present and writable

Then I do this, php artisan cache:clear which gives me a new error:

Class view does not exist

Then after that no matter what I do either in terminal or viewing the web browser, I always get the error

Class view does not exist

Then I have tried composer update still the same error.....what am I doing wrong?

This has been a nightmare.

like image 562
user979331 Avatar asked Dec 05 '18 21:12

user979331


5 Answers

Last time i checked Laravel doesnt run on XAMPP but rather on the PHP installed when installing XAMPP so the project can be saved anywhere on the computer.

Given this being the fact, you will need to just have an active PHP installation and then you copy only the relevant files of the project onto the new computer (such files that you will get when you push your project onto GitHub). It doesn`t come with cache issues then all you need to do afterwards is to

php artisan key:generate

then composer install or composer update to get the vendor packages from online

My money right now is on picking the relevant files and reinstall with them According to my own installation when changing the computer this is the list you will have to copy enter image description here

like image 109
Flash Avatar answered Nov 19 '22 17:11

Flash


I just tried to reproduce your issue on my mac. So i have installed XAMPP with the PHP version 7.1.25 which is the equivalent version of my local PHP version

So I installed the XAMPP and started server.

Downloaded my laravel project folder from my ubuntu server and copied it to htdocs (XAMPP)

When i tried to run http://localhost/myproject/public it shows the exception like

There is no existing directory at "/Applications/XAMPP/xamppfiles/htdocs/myproject/storage/logs" and its not buildable: Permission denied

Then i gave full permission to the storage folder

chmod -R 777 storage

And changed ownership for the files inside myproject folder.

Here i just checked the ownership of the dashboard directory which is running perfectly and given the same user ownership of myproject directory.

chown -R root:admin .  

Then following commands

composer install
php artisan cache:clear
php artisan view:clear
php artisan route:clear

After this my laravel code runs perfectly.

Class view does not exist

is probably a ownership issue of the directory

like image 4
Naveen K Avatar answered Nov 19 '22 18:11

Naveen K


For me (when developing on xampp, what I do for all my projects) - I'd not recommend to put your stuff in the htdocs folder. Laravel expects to not be hosted on a subfodler e.g. (localhost/my-project). So you should set up a virtual host in order to make it work easily (e.g. my-project.test) which is a bit annoying.

Simple solution is using the php artisan serve command in order to simply setup a local server on port 8000.

Don't forget to start xampp for the mysql server.

Some typical tips were already mentioned:

  • delete vendor folder & run composer install (install composer if you haven't)
  • run composer dump-autoload
  • run php artisan key:generate
  • ofcourse don't forget the migration php artisan migrate
  • and clear your full cache php artisan cache:clear

Usually you do not need to set any file permissions afaik

like image 2
Frnak Avatar answered Nov 19 '22 18:11

Frnak


chmod -R 777 storage/

If you have a different user for apache2 (usually www-data), also do:

chown -R www-data storage/

You could also check if it runs with the built-in server:

php artisan serve

like image 1
eselskas Avatar answered Nov 19 '22 17:11

eselskas


You can create .htaccess file and add below data into .htaccess file

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REQUEST_URI} !^public
 RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

After create .htaccess file, set laravel root path in terminal and run below command in terminal

php artisan serve
like image 1
Jinesh Gandhi Avatar answered Nov 19 '22 17:11

Jinesh Gandhi