Simple PHP Server

Hey guys I am in a rush and I need to create a simple php server with a few Rest API’s. I cant seem to find anything that works so far so if any of you would know how I could create something really basic.

No LEMP or LAMP? I don’t know if it gets more basic than that. Maybe install XAMPP and enable all the services?

Digital Ocean had one click droplets. That’s where you check boxes for services you want and create the droplet. The server fires up with everything you checked. I know they have OwnCloud/Next Cloud options, which requires PHP

2 Likes

What I mean to look for is the php source code that I give to LEMP or LAMP.

use your OS’s package manager (e.g., yum, apt) to install it.

Are you installing on a server? or for development? For development, strongly recommend running your server as a VM. Check out http://puphpet.com (these can be deployed to digitalocean et. al., as well).

No, I dont have an issue finding the program that runs the code. I am having a problem finding the boiler plate for some basic RESTful API’s.

This is small project, I am not worried about deployment beyond my local machine.

ah — ok, I follow. You might look at something like slim, lumen, or silex. PHP isn’t like some other web languages where there is a “standard” or de facto way of doing an api; so pick a framework. :slight_smile:

1 Like

I tried installing Lumen with composer and I keep having these issues

image

it’s saying it requires php 7.0 or newer.

I highly, highly recommend upgrading. NO new project should be using php 5.
http://php.net/supported-versions

7.1 is the current version. google “php 7.1 {your OS name}” to figure out what repo/ppa you’d need to use.

thanks, I installed php 7 but now its giving me this issue. I googled some solutions but none so far have worked to fix this.

image

what OS is this? I’m guessing Debian? I think the package is php71-mbstring. would depend on how you got php 7.1 (e.g., a ppa?).
use apt-cache search keyword to search for packages on debian.

Alright I think I am getting closer. When I try making a new project it gives me an error but the project is still made.

image

When I run the project and connect to it with a browser it gives a error.

image

first issue is same as your other issue; your php installation is missing a required extension (DOM). The screenshot you showed was not a “successful” installation. Find and install the DOM extension.

as for the second, I would discourage the use of the built-in php “server.” it’s not all that great a tool, and is completely unlike anything you’ll be using in production.

Do you understand the error message (re: require)? Compare file paths.

It looks like its looking for a file. That file is not in the project so I was wondering if the first problem caused this issue. I was wondering if the first problem caused the second issue.

Alright it looks like I fixed the first issue and that fixed the second issue!

in this case, yes, the autoloader probably doesn’t exist because you haven’t yet successfully installed the project.

just to be sure, check the path reported in that error message. is that the path you expect it to be?

edit

cool!

Now I am trying to make a simple route that checks a database and returns true or false if the username and password is correct then I want to return true. Would you know how to take an argument from route that is called from a ajax call?

“from ajax call” is not relevant. it’s all exactly the same.

assuming you’re using html forms, submitted values are in $_GET or $_POST depending on http method.
if you’re submitting a plain json blob as the request body, you’d need to read and parse php://input yourself.

just to be sure, you’re using http://php.net/password for your passwords? :wink:

You wouldn’t happen to know what this means?
image

I have been searching around for a solution but after trying several different things that I have read online I was unable to find a solution that fixed the problem. I am running on Linux mint btw.

do you really need to run with PHP?

I’m just saying because I know a single line of python to get a webserver up and rolling.

python3 -m http.server

Yes

Gonna be honest here, this is for one of those classes where its just a GPA booster. The class does not grade hard or even have exams. The server has to be PHP so I am just trying to throw some shit together so I can go back to working on a senior level algorithms course that I need to put more effort into because I find it pretty tough.