0

I'm trying to build a PHP API. So far I've implemented the model of the API using a class called API, having all the methods for adding/removing/updating etc. I want to make an API, so that e.g.:

example.com/post/add/data...

Turns into a request, which calls the proper methods of the model. I just have no idea about how to turn URL/URI's into method calls of the model class.

2
  • Have a look at the routing part of the Codeigniter source. It doesn't exactly that. Basically just parsing $_SERVER['REQUEST_URI']. Commented May 3, 2015 at 13:59
  • I actually wanted to do something very much along of what CodeIgniter does, just had no idea how they implemented it. Commented May 3, 2015 at 14:16

1 Answer 1

1

Try comming up with scenarios: 1. If you get a post request type then you must add a product for ex 2. If the script doesn't deceive a POST params it wants to get atuff (json format for ex) 3.etc Implement based on your needs basically.

A usefull example here:http://code.tutsplus.com/tutorials/a-beginners-guide-to-http-and-rest--net-16340

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.