So I'm working on a project with many files and folders. I'm using Laravel and localhost to run it locally on my browser. It runs the project fine, the problem is when I try to run a single file by itself(by right clicking on vs code and clicking PHP Server: run file in browser) to test and see what I'm doing. Doing that returns an error (localhost unexpectedly closed the connection). What could be the problem and how should I fix it or what other way should I try to run one specific file as opposed to the whole project. If there's anything from the code you might need, please ask
CodePudding user response:
Laravel is a framework that needs to be booted before all its services are available.
These services, and the request cycle as a whole, are started via the index.php file in the public folder. This is a single entry point for all http requests. There is another entry point via the artisan command for CLI operations.
You cannot run individual files in the manner described because they are taken out of context of the framework.
CodePudding user response:
If you are developing on MAC or Windows you can download MAMP: https://www.mamp.info/
This will make your make into a local server. Then just redirect your directory to your server and run it.