why?
node.js with laravel
I would really like to start developing Laravel application with Node.js
take advantage of node.js in some cases -realtime and databending - jquery is really painful I've struggled with last app
I'm pretty much sure it would be best practice to use node.js
node.js is server side javascript. jquery, while it can run on node, is generally a client-side library.
Perhaps you should explain what you're actually hoping to accomplish. Right now you're comparing apples and oranges, so neither could just outright be called "best practice"
If you could explain a case in which you think you would need both technologies, it might be easier for people to give you some help/direction.
NodeJS and Laravel are both server side technologies, using the two in conjunction doesn't really make much sense without a little understanding of what you're trying to accomplish.
If you're interested in real-time communication, take a look at Pusher it's a great library and Jeffrey has a tutorial on it.
If you want to run node.js and POST or GET stuff to/from your Laravel app, it will work fine. As stated above, please tell us what you want to accomplish :P
Use the MEAN stack instead of mixing Laravel with NodeJS.
thank you all guys
If what you're really after is realtime push of data to the client, without needing an external service like pusher, look into the php library Ratchet. That will likely keep things simpler for you than managing both a php app and a separate node server.
You certainly could create a basic node server to shuttle messages back and forth between the client and your php app, but you would need to implement a method on the server side for the node server and php app to talk to each other. You would also, likely, need a php service that's running all the time.. you're probably better off just using one or the other, and if you opt for laravel, leverage the queues and ratchet to push notifications and whatnot as needed.
thank you very much willvincent I appreciated
Using both doesnt makes sense unless you find the benefit using one node.js has one great plus point on handling multiple thread in less execution time while php takes in a bit longer along with you can find the best packages https://www.npmjs.com/ here at npm :) hope this would help
You can use github project https://github.com/ahmedawad250/laravel_nodejs_redis_realtime it is a simple send messages realtime project using laravel,nodejs and redis server
You can also try https://socket.io/ + laravel that should work perfectly with your real-time application.
I have a case where I actually require to work with node and laravel - I have an application where I need to generate PDFs with lots of infographics and charts and different fonts - DOMPDF has been a pain in the past so I have many wonderful libraries for Node - so I would like to use node.js and its library just to create pdf from the data and to use it through laravel.
So, while it is possible, I have not seen a practical implementation of executing PHP scripts through Node.JS.
There are a few places you'll need to start looking, as I think I understand what you're going for. You'll need to look into a few RFCs, particularly HTTP 1.1 and CGI/FastCGI, from the IETF to get proper specifications. You'll also need to dig into how to execute php-cgi.exe (or your equivalent executable in a *nix environment) and pass it the proper global variables. (You'll be looking into the child_process library in Node for this.)
Global variables are populated into PHP by the webserver running it, be that Apache, Nginx, or your custom node solution. As such, you'll also need to get familiar with the technical aspects of global variables in PHP. The official PHP documentation is a great source for this. Other good sources may be documentation on the subject from Apache or other server applications.
While this is all possible, it's important to note that the benefits of your use case need to outweigh the cons of having to write an enterprise level web server capable of the same functionality as current widely available server platforms to ensure you're getting the most out of your PHP Laravel application. That said, it is absolutely possible that such a use case exists, and if you are familiar enough with security in Node.JS, it is definitely doable, though no small feat.
Happy coding!
Please or to participate in this conversation.