Let's see how to host Laravel project on 000webhost.
First, we need to zip our project folder. We need to zip the project which runs successfully on the local machine. For that we will use PHP ARTISAN SERVE command to see if it is actually running properly.
After that we need to download the database of the project. To download the database, you need to export the database from PhpMyAdmin.
Next, we need to upload the complete zipped project inside the webhost. And in this tutorial, we will teach how to deploy Laravel project using free hosting. 000webhost is a very good free hosting website. We will use the free service of 000webhost in this tutorial.
After that we have to create the database of the website. For this we will create a new database from 000webhost's database manager. Then we will import our exported database into hosting database.
Then unzip our project. If the system does not unzip it, we will do it through the Unzipper.php file.
Next, we will move the project folder to the root folder and move all the files and folders inside public to public_html.
Then, we will edit the .env file according to the hosting database name and username, along with the correct hosting database password.
Then copy the complete code of App_key= base64:
Then go to app.php from config folder and replace
'key' => env('APP_KEY',base64_decode('YSWQ7lRz8BgJgnZSTH38mHgqWAZy5TvySYn6m8hMBX8=')),
instead of
'key' => env('APP_KEY'),
Then go inside public_html and change these two locations of index.php
require __DIR__.'/../MyProject/vendor/autoload.php';
$app = require_once __DIR__.'/../MyProject/bootstrap/app.php';
Here, replace MyProject with the folder name of your project. Then add the following code after this line $app.
$app -> bind('path.public', function()
{
return base_path('public_html');
});
Then go inside the config folder and edit the Database.php file in the MySQL part according to your hosting database.
Then the project will run.