I'm new to Zend Framework and MVC typing programming (though not PHP) and I try to provide API access Data on my server using Z Framework
I am using Chris Danielson's article as a base.
I want to give access to the data in the following formats:
(a) http://www.example.com/api/createevent data will be posted here , Success will return an ID, otherwise an error message / code (b) http: // www .example.com / api / geteventdetails / 1234 will return the GET request data (c) http://www.example.com/api/ Getregistrationdetails / 1234 GET request data will return (d) http://www.example.com / Api / getregistrationdetails / 1234/567 GET request data will return question:
-
is a default file located \ api \ A Pplication \ controllers \ VersionController.php that enables URL type handling: am I creating a separate file : \ api \ application \ controllers \ GeteventdetailsController.php that type of Handles requests (B) (and one for each request)? If not, then where should I place my code to handle many of these codes? -
How do I get the parameters passed from (B) to (D)?
-
To request (B) to (D), I need to bring information from the database of my server where should I place a code containing the actual MySQL query?
I have used a lot of routes in ZF, but the rest With the implementation of, swaps on docs and tutorials you've linked - I'll try my best to help you ...
This could be (about 1/3 below page) Noteworthy on docs - This indicates that it will automatically make the route for you based on the request method; Therefore, your nomination form of createevent , geteventdetails should not be required. Question 1. Instead of creating a file
\ api \ application \ controllers \ geteventdetailsController.php
I will create the file < / P> It will be a controller to control all controller tasks, getting, posting, inserting , e.t.c.
Question 2 Routes mentioned in : The suggestion for the controller is very specific, as will be done at the verb level, such as mill, plate etc. Docs shows you that the last parameter (: ID) will be assigned to the parameter in the controller named id then receive / events / using indexAction () will enter your EventsController. Using php file and / events / 99 / received will use getAction () In your EventsController.php file, you can access this ID from the controller in this way $ id = $ this-> getRequest () - & gt; GetParam ("id"); or $ id = $ this- & gt; GetRequest () - & gt; Id; You should write the code for the list of events or to query the database for a specific ID. Which brings us well ...
Question 3. to do this. This ensures that your application / website is MVC. After entering the code inside the code, you can interrupt development, for example when you write a registration form for any event in any other controller, the argument will be repeated for creating an event, one Times in the new controller and once in the comfort controller.
I hope that helps! You want to make this argument better than intermediate in a model.
Comments
Post a Comment