<p>The confusion might come from the concepts behind the tools you are using. So let's start with a little definition.</p>

<blockquote>
  <p>Laravel and Artisan</p>
</blockquote>

<p><strong>Laravel</strong></p>

<p><em>Framework</em> for building a full MVC Web application in PHP. It is the equivalent of Spring-boot with Java or Rails with Ruby.</p>

<p><strong><a href="https://laravel.com/docs/5.0/artisan#introduction" rel="nofollow noreferrer">Artisan</a></strong></p>

<p>Laravel's console driven interface for development. It provides tools such as the web server coming with PHP 5.4+. When using the "serve" command a simple web server will start. This is perfect for development, but I would suggest you use a server that gives you proper configuration flexibility in production such as Apache or nginx.</p>

<blockquote>
  <p>Your other thoughts</p>
</blockquote>

<p><strong>Java/Ruby/PHP/Javascript</strong></p>

<p>Are programming languages. Node.js is like an ecosystem that allows you to run client/server/middleware/tools Javascript based applications. Someone did a great job of comparing it with a Java ecosystem. <a href="https://dzone.com/articles/what-is-nodejs-for-java-developers" rel="nofollow noreferrer">Right here</a>.</p>

<blockquote>
  <p>But is <code>Laravel artisan serve</code> possible for production?</p>
</blockquote>

<p>In theory, yes. It would require your development setup to be in production as well. Hence from this assertion, the answer becomes self evident for security, operability, configuration and performance to name a few. You will need a different configuration for production.</p>

<blockquote>
  <p>How to serve RESTful API?</p>
</blockquote>

<p>No matter which language you use, choose a library or a framework that will give you the tools to implement your APIs. Since Laravel is your framework, you can take a look at this tutorial to <a href="https://medium.com/@devlob/creating-apis-in-laravel-5-5-using-api-resources-9850c1b70efb" rel="nofollow noreferrer">get started</a>.</p>

CC BY-SA 3.0
2017-12-03T17:30:06.080Z
2017-12-03T17:30:06.080Z
gmolaire
<p><strong>Background:</strong>
  I am developing a Web application for Employee Management. I use <code>Laravel</code> for building a RESTful API, and (maybe) <code>ReactJS</code> for the frontend.</p>

<p><strong>My problem:</strong>
  I am confused on how to deploy my application. My current plan is to use the command <code>Laravel artisan serve</code> for the RESTful API, and use <code>Nginx</code> for serving HTML files. But is <code>Laravel artisan serve</code> possible for production? How to serve RESTful API?</p>

<p><strong>Some other thoughts:</strong>
  As far as I know about <code>Node.js</code> applications. We can use <code>ExpressJS</code> for building a RESTful API, then <code>pm2 start app.js</code> for production. But <code>Node.js</code> is good at serving dynamic contents. If I build the RESTful API with <code>Laravel</code> or <code>Spring Boot</code>, or <code>Ruby on Rails</code> (<code>Sinatra</code>), I don't think a command like <code>pm2 start app.php (app.java or app.rb)</code> will work (here <code>pm2</code> is only for convenience, I know it is only for a Node.js app) because <code>PHP</code>, <code>Java</code> or <code>Ruby</code> is quite different from <code>Node.js</code>. I am afraid I am missing something fundamental here.</p>

CC BY-SA 3.0
2017-11-30T03:27:15.780Z
Maybe worth mentioning the infra *where* you're deploying. Most likely deploying on a PaaS solution is different than deploying on a IaaS one, for example.
Dan Cornilescu
CC BY-SA 3.0
2017-11-30T07:35:35.130Z
Thanks for your comment @DanCornilescu, I am deploying on an internal server of our company.
shintaroid
CC BY-SA 3.0
2017-11-30T10:38:21.387Z
You should really take a step back and read some tutorials about serving a php application be it built with alravel, symfony or from scratch on production grade configuration. Searching google for "laravel deploy to prod" brings the documentation about it in firsts results: https://laravel.com/docs/5.5/deployment , for java that's another story , and for RoR also (sinatra is not RoR at all and more an alternative). There's a full world of practices around each of them and the methodology will be different.
Tensibai
CC BY-SA 3.0
2017-12-01T01:23:28.230Z
Thanks, @Tensibai. I do need to learn more about the Laravel ecosystem.
shintaroid
<deployment>
How to serve RESTful APIs?
shintaroid
# How to serve RESTful APIs?

(Asked by: username_0 on 2017-11-30)

**Background:**
I am developing a Web application for Employee Management. I use `Laravel` for building a RESTful API, and (maybe) `ReactJS` for the frontend.

**My problem:**
I am confused on how to deploy my application. My current plan is to use the command `Laravel artisan serve` for the RESTful API, and use `Nginx` for serving HTML files. But is `Laravel artisan serve` possible for production? How to serve RESTful API?

**Some other thoughts:**
As far as I know about `Node.js` applications. We can use `ExpressJS` for building a RESTful API, then `pm2 start app.js` for production. But `Node.js` is good at serving dynamic contents. If I build the RESTful API with `Laravel` or `Spring Boot`, or `Ruby on Rails` (`Sinatra`), I don't think a command like `pm2 start app.php (app.java or app.rb)` will work (here `pm2` is only for convenience, I know it is only for a Node.js app) because `PHP`, `Java` or `Ruby` is quite different from `Node.js`. I am afraid I am missing something fundamental here.

**Tags:** deployment

> **Comments:**
> **username_1**: Maybe worth mentioning the infra *where* you're deploying. Most likely deploying on a PaaS solution is different than deploying on a IaaS one, for example.  
> **username_0**: Thanks for your comment @DanCornilescu, I am deploying on an internal server of our company.  
> **username_2**: You should really take a step back and read some tutorials about serving a php application be it built with alravel, symfony or from scratch on production grade configuration. Searching google for "laravel deploy to prod" brings the documentation about it in firsts results: https://laravel.com/docs/5.5/deployment , for java that's another story , and for RoR also (sinatra is not RoR at all and more an alternative). There's a full world of practices around each of them and the methodology will be different.  
> **username_0**: Thanks, @username_2. I do need to learn more about the Laravel ecosystem.  

---

## 1 answers

### Answer by username_3 on 2017-12-03. Score: 2

The confusion might come from the concepts behind the tools you are using. So let's start with a little definition.

> Laravel and Artisan

**Laravel**

*Framework* for building a full MVC Web application in PHP. It is the equivalent of Spring-boot with Java or Rails with Ruby.

**[Artisan](https://laravel.com/docs/5.0/artisan#introduction)**

Laravel's console driven interface for development. It provides tools such as the web server coming with PHP 5.4+. When using the "serve" command a simple web server will start. This is perfect for development, but I would suggest you use a server that gives you proper configuration flexibility in production such as Apache or nginx.

> Your other thoughts

**Java/Ruby/PHP/Javascript**

Are programming languages. Node.js is like an ecosystem that allows you to run client/server/middleware/tools Javascript based applications. Someone did a great job of comparing it with a Java ecosystem. [Right here](https://dzone.com/articles/what-is-nodejs-for-java-developers).

> But is `Laravel artisan serve` possible for production?

In theory, yes. It would require your development setup to be in production as well. Hence from this assertion, the answer becomes self evident for security, operability, configuration and performance to name a few. You will need a different configuration for production.

> How to serve RESTful API?

No matter which language you use, choose a library or a framework that will give you the tools to implement your APIs. Since Laravel is your framework, you can take a look at this tutorial to [get started](https://medium.com/@devlob/creating-apis-in-laravel-5-5-using-api-resources-9850c1b70efb).


---

