Simple PHP Server

Alright, good luck!

thanks

After this is done I get to go back to working on writing proofs and algorithms on graph theory.

specifically, no; other than it wants a file but can’t find it.

is there a reason you’re running php with root? e.g., did you install composer with root? recommend you don’t do that.

also recommend you not use php’s built-in dev server, for anything. it’s pointless; there’s weird setup stuff to do anything useful, and there’s no benefit in the end. run a real webserver (possibly in a VM, e.g., if this is your desktop machine).

Ok well I read the instructions again and I found I was trying to be way more complicated. I need to have a html, javascript, php files locally and call the php file locally to do something. When I try posting to the file I get this.

image

image

http://puphpet.com

this is plain old CORS, though, nothing to do with php. it’s because you’re using file:///.

Second. Http requests have to be done with something running a webserver like apache. Javascript stuff will work with a plain old html file like that but php won’t.

I use Laravel on a daily basis (Lumens big brother), let me help.

  1. First, make sure your php7 install is setup correct.
  2. Next, you will need both the mcrypt and mbstring extensions. Google how to install those for your system.
  3. You will need to make sure the project is installed correctly. “composer install”
  4. You dont need to use PHPs built-in web server. In the root of your project, run 'php artisan serve`. This might not work with Lumen, I cannot remember.
  5. If the above command does not work, you might have to use the built-in web server. Go into the projects “public” directory and start the web server from there.

Feel free to bug me if you have any additional questions. I do this for a living so I am sure I can help you out.

I dont think I am going to use a framework. What I am supposed to do was a lot more simple than I thought. I appreciate the help but it wouldn’t be worth it make this into an actual project.

1 Like

It really is quite simple, install apache2, do some setup, install libphp-apache or whatever it is called, restart the apache 2 service, e.g. 'sude service apache2 restart.
And you’re rolling.
_GET[‘XYZ’] gets a parameter from the arguments sent from the client, and hell you can use file_put_contents(yada yada yada) on the client side.
After this setup it is a matter of coding your own RESTfull service. be it dumping content into a DB, or logging wierd emotes for later use, or maybe count cats for each insert into a database(It does get wierd sometimes as a developer).
My point being it is simple.
setup a server->code>win. There is no need for all kinds of fancy schmancy frameworks todo the job for you, as long as you know “what you want” somewhat.
PHP is by far the easiest language to program Rest services in.

There’s this:

http://www.zachsaw.com/?pg=quickphp_php_tester_debugger

Windows only though.

something something php 5.3

I really don’t understand what it is everyone has against running a webserver on a VM for dev. it’s all pros and zero cons.
and it’s soooooo easy.

O thanks I didn’t know that it was using an old version like that.

1 Like