If I understood correctly the xml and/or json output is /public/index.php as stated in configuration in docs. If yes, then how will it find my classes what I want to do?
If I should instantiate my classes myself in a controller script then how to output json/xml data as my controller script link is not public/index.php?
Or after outputing data, I should then read the output in json/xml format from that link then echo it in my own controller?
In other word, do I need to use first setBody then getBody in my controller script?
Those questions are too vague to answer in any meaningful way - I’d suggest trying to work through the documentation and examples that I gave you the links for and see how far you get. If you get stuck, feel free to come back and ask a more specific question about the problem you’re having.
Actually I did read docs before posting. For example this one http://phpsx.org/doc/concept/import_data.html#entity
Imagine I wrote a file Blah.php and in this class I called phpsx api then import() to output fetched data from db on /public/index.php…
Now how I get this import() output on /public/index.php? Or how to send request to /public/index.php to get the answer imported by Blah.php class?
I just realised that I deleted the links from my original reply, sorry about that! The example code I was referring to is here: https://github.com/k42b3/psx-examples
If I understand your question correctly, you would have a routes file similar to this (this is the one from the example on github):
GET|POST|PUT|DELETE /population PSX\Example\Api\Collection
GET /population/:id PSX\Example\Api\Entity
So a GET request to the URL api.example.com/population will route to the doGet() method of the Collection class (Collection in this example seems to act as a controller) and POSTing to the same URL will route to the doCreate() method. Does that help?
I think /internet/1 requires a database? with just root access to /public/ I get 500 error and with /tool/rest I get an image of my root homepage so all css/images are broken. I guess the problem should be the .htaccess of my public folder? how should it be?
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.php/$1 [L]