简体   繁体   中英

Taking Laravel-5 project from Localhost to server

I am new to laravel framework. Recently I have made a simple blog type website. In localhost it working good without any problems, if any problem arises then I used to do composer update , composer dump-autoload , etc.

But when I migrate it to the server got the following error. What is this error, should I have to run composer update again? If yes then how can I run it on my server. I have no idea on this matter, please help me.

Warning: require(/home/somedomain/public_html/CMS/app/http/helpers/backend/helpers.php): failed to open stream: No such file or directory in /home/somedomain/public_html/CMS/vendor/composer/autoload_real.php on line 58

And the next error is:

Fatal error: require(): Failed opening required '/home/somedomain/public_html/CMS/app/http/helpers/backend/helpers.php' (include_path='/home/somedomain/public_html/CMS/vendor/phpunit/php-text-template:/home/somedomain/public_html/CMS/vendor/phpunit/php-timer:.:/usr/lib/php:/usr/local/lib/php') in /home/somedomain/public_html/CMS/vendor/composer/autoload_real.php on line 58

I am doing this project in Laravel5. If the error was due to index.php then here is my index.php :

<?php
/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylorotwell@gmail.com>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/

require __DIR__.'/CMS/bootstrap/autoload.php';



/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/CMS/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make('Illuminate\Contracts\Http\Kernel');

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

My main project directory is starting with CMS folder. In the same CMS directory I have a index.php and inside the CMS folder I have an app , bootstrap , config , database , vendor folder and many. When I remove all code of index.php and write <?php echo "Hello World"; ?> <?php echo "Hello World"; ?> and go to my site somedomain.com I get "Hello World "`` as output. How to solve this error?

First of all, if you like to run your laravel project on a shared host this should be possible. Just upload the whole project including the vendor dir to your server.

Make sure that your domain points to the public folder inside your laravel project.
If you like to access your project inside a sub folder of your domain (eg http://your-domain.com/your-app/ ) then you need to make some changes. Here is a how to for Laravel 4 which should work for L5 too.

If the error still occurs then make sure that your folders and files are in the correct upper/lower case. If your localhost is a windows machine (which makes no difference between upper and lower case) and you move to a linux server (which differentiates upper and lower case) you can run into problems. Therefore make sure your paths and filenames in your code are in the same upper/lower case as they are on your server.

To avoid problems like this I can recommend the use of Laravel Homestead . It's a virtual machine environment for laravel development.

Which server do you use ? Check if your path is defined in the config folder. Also install all the dependencies in the right folder and copy all of them to your server. You can check this link for a proper installation https://laracasts.com/series/laravel-5-fundamentals . Most likely you're missing some files. Try reinstalling the project.

I guess you will need to change the base path from localhost to your domain in order for it to work. This worked for me though when i got the same error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM