Question

I've successfully installed laravel version 4.1.24 (using softaculous) on my production server and now I want to move my application from my local machine to the production server (cPanel-type web hosting) but I'm having a bugger of a time figuring out how to do it. I've found a few forums online discussing similar problems but nothing has helped me yet. Which files do I need to move? Can I move them via FTP? I'm not familiar with any other method.

More detail: When I copy over all of the critical files in the "app" and "public" folders I get an error that it doesn't recognize my model classes. When I copy over everything (including "vendor" and "bootstrap" it still doesn't recognize my model classes). Someone's has to have done this before. What did you do?

Update:
I'm getting closer to the problem. I started with fresh installations on both my local and production environments and moved/overwrote files for the following folders:
/app/controllers
/app/models
/app/views

Also moved/overwrote the app/filters.php file. Besides the "public" folder this encompasses pretty much my entire application so far.

I then copied over a super-slimmed-down app/routes.php file that has only one route:

Route::get('/', function()
{
$users = User::where('id', '<' ,'100')->whereNotNull('first_name')->get();

    foreach($users as $user){
        echo $user->first_name . '<br>';
    }
});

This worked as expected on both the local and production! I then changed the route to the following:

Route::get('/', function()
{
$cars = Car::where('id', '<' ,'100')->get();

    foreach($cars as $car){
        echo $car->name . '<br>';
    }
});

This works just fine on the local environment but in the production it returns a "Class 'Car' not found" error. This is my problem and I think that user2094178 was onto something when he/she mentioned running "composer dump-autoload". Any idea how to do that remotely with cPanel?

Update #2
I found this thread: How to avoid using php composer dump-autoload with laravel 4?. This seems to be addressing exactly the same issue. Except that all of my models are already in the "models" folder so the line app_path().'/models', should already be loading my classes. Right?

Also, I've found the "bootstrap/autoload.php" file that says this in the comments:

"Composer provides a convenient, automatically generated class loader for our application... We'll require it into the script here so that we do not have to worry about the loading of any our classes 'manually'."

This is followed by:

require __DIR__.'/../vendor/autoload.php';

I'm scared to modify this file because I have no idea what I'm doing in there. This has then lead me to a few other files with the same lack of direction. Any ideas?

Update 3:
Looks like Laravel 3 had something like this: http://three.laravel.com/docs/loading. I need to find out how to do it in Laravel 4.

Was it helpful?

Solution 2

When I receive a not found controller class from laravel, it means I forgot to run composer dump-autoload.

To avoid it, open the file app/start/global.php and certify you have the desired path within ClassLoader::addDirectories array.

It worked fine to me without the need of composer dump-autoload. Since it doesn't scan subdirs, you may regret using it when you start to organize your models and controllers by dirs.

If you are willing to consider using namespaces to free yourself from composer dump-autoload, please read the following:

https://github.com/daylerees/autoload-demo

OTHER TIPS

You must copy all the files, and be careful with the conf/local, mabe you have some configuration on your local that isn't in your genral file.

Remember you need to have installed

PHP >= 5.3.7 MCrypt PHP Extension PHP JSON extension

If you are going to work developing web apps, you should learn a version control software, git, mercurial.

With git, moving your project to production is as easy as typing a command in your shell and you can keep a copy of your code safe in another place like github or bitbucket.

You also have more complex deployment software like capistrano, they give you full control of your deployments.

Even you can use a php as a service place like http://fortrabbit.com/

I recommend you any of this much more than using ftp.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top