How to host a Laravel website on Netlify? - laravel

I'm trying to host my Laravel website on Netlify.
I was originally using Laravel Forge to deploy and host my website.
The deploy script that was used on Laravel forge was:
cd /home/forge/lucaban.com
git pull origin master
composer install --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.1-fpm reload
if [ -f artisan ]
then
php artisan migrate --force
fi
Is there any way I can host the website on Netlify and run these composer commands? Because I think I can only insert NodeJS commands into the build command input.
I have not yet succeeded getting my website live...

You cannot host a laravel site on Netlify. Check out https://jamstack.org for more about the philosophy behind Netlify's hosting service.
While you can use php in the build environment (composer install should work, though you may want to set PHP_VERSION to 7.2 since the default is 5.6), the build process is intended to create static output files - html, css, js, images, etc - which Netlify can then serve from its CDN without running any more code on the server side. While the comparison is not quite perfect, imagine that the output from your build (limited to 15 minutes and no incoming network connections) is a bunch of files, which are stored on S3 and served as-is. So if you end up with file.php - Netlify would show, not run, the code in the file.
You cannot host a laravel, wordpress, drupal, magento, etc site on Netlify, though it is Netlify and the JAMstack movement's assertion that you don't need a legacy website that runs code at every visit to run much of the web and that there is great value in reducing the dynamic portions of a website to small services, such as form-handling or lambda functions. Here's a case study on a customer who migrated their site from wordpress to Netlify and includes authentication, comments, and e-commerce: https://www.netlify.com/blog/2017/03/16/smashing-magazine-just-got-10x-faster/

You may want to have look at Vapor which is a serverless deployment platform for Laravel:
https://vapor.laravel.com

Related

If I run it on laravel localhost, it shows me only file, how to fix it

If I run laravel on localhost, it shows me only file, how to fix this
The main index.php file is in Laravel's public/ directory. If you visit http://localhost/Employee/public, you'll likely see your Laravel site.
If you point your webserver's DocumentRoot at that directory, you'll be able to visit the app at http://localhost/. If you want to run multiple apps locally, you'll want to start playing with virtualhosts.
Alternatively, consider using Laravel's Valet, Sail, or Homestead options for local development; each will handle this sort of thing for you. Sail is Laravel's current recommendation.
You can use a web server such as Apache or Nginx to serve your laravel applications. If you have PHP 5.4+ and would like to use PHP's built in development server you may use the serve artisan command:
cd /project_directory
php artisan serve
By Default it will run application on port 8000
If you want to change to other port specify port number like
php artisan serve --port=8080
It will run your application on the PHP development server on localhost:8080
Docs: https://laravel.com/docs/4.2/quick#local-development-environment

How To Upload Laravel with vuejs To Shared Hosting

I upload my laravel project in Host domain i work with laravel and vuejs, any easy way to deploy it?
Just follow the following steps to deploy your Laravel and vue.js application to a shared hosting.
generate your product vue build using npm run prod
upload all the changes and project to a git repository.
clone your git repository to your shared hosting, mainly via integrated terminal in some shared hosting or via ssh key access.
redirect your domain or subdomain directory to /public folder.
run composer install
run cp .env.example .env
setup .env files according to database configuration and emails etc.
run php artisan migrate
run php artisan key:generate
run php artisan storage:link if you want media uploading to your server.

How to setup laravel 7 on shared hosting?

I recently transposed an existing web site from symfony to laravel for which I am a newbie.
At the moment my site is running with Laravel locally using the embedded server.
I created a repo on github and pushed my site on it.
Then I connected to my site via ssh and cloned the github repo on the remote server (shared hosting).
I created a .env file from the .env-example remotly.
I created a subdomain that points to the public folder of the cloned site.
I modified a line in public/index.php to
$app = require_once __DIR__.'/bootstrap/app.php';
I launched a composer update command and then run
php artisan key:generate it returned success but I couldn't find any key in the .env file thus I used the same key I use locally.
When I visit the subdomain I get a page like this one:
Index of / Name Last modified Size Description cgi-bin/
2020-09-13 15:23 -
I very probably missed something

Deploy with Laravel?

First Laravel Project.
I want to deploy my Laravel project to a Hoster. I have FTP access to it, but I don't want to tinker with filezilla everytime I change something. Plus my Development and 'Finished' projects has some differences (for example Debugbar and different DataBase authentication. What's the best method to deploy a Laravel Project?
It can be done in many ways. So I am going to give a headstart.
Warning: This might not be everything you need to know. I recommend you to learn more about, deployment,ssh, version controlling, apache vhosts, etc , this is just a headstart
Here is how I do it on my Ubuntu server with apache, php and mysql.
I use Git for version controlling and bitbucket and github for managing repositories.
1 - make my project a git repository.
2 - push the repo to bitbucket.
3 - connect to the remote server through ssh and setup the apache vhosts, databases etc.
create a vhost /etc/apache/sites-available/somesite.com.conf file
add the entry to /etc/hosts file
4 - pull the repo from bitbucket to remote server, create and bring the required changes to the production .env file
5 - do a composer install
6 - run php artisan key:generate and php artisan migrate
7 - turn on the site
run sudo a2ensite somesite.com.conf
run sudo service apache2 reload
now the site its up and ready to go.

Lumen not working out of the box

Just installed Lumen framework.
hit the link http://localhost/lumen/public/ in my browser and got this following error, anyone got any idea about it?
Traced it back to the app.php file in bootstrap folder.
if You want to access lumen project without "php artisan serve"
$app->run(); replace with
$request = Illuminate\Http\Request::capture();
$app->run($request);
from this path yourlumenproject/public/index.php
Open your terminal in the root folder run the following command php artisan serve.
Lumen development server started on http://localhost:8000/
if you want to serve your app in local development you can do this :
php -S localhost:8000 -t public/
and it will serve in localhost in port 8000. hope this help.
Note : I'm using Laravel Framework version Lumen (5.2.4) (Laravel Components 5.2.*)
At the moment Lumen only runs in the domain root.
(I've submitted a PR that fixes this but it has yet to be merged)
You have to create a Virtual Host on your local webserver and point the document root of that to the public directory. After that you can access your app with something like: http://lumen.dev.
Guide for Virtual Hosts with nginx
Guide for Virtual Hosts with Apache
A simple alternative to setting this up manually is Laravel Homestead. It is an official Vagrant box made for Laravel, that allows you to easily get your development environment up and running.

Resources