Please see this and its docs

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?

Hi nimasdj,

I’m not entirely sure I understand what you mean.

Are you asking about how requests are routed to the correct controller? Are you familiar with the Front Controller pattern that most frameworks use?

Please advice how can get that PHPSX working? How to send request and how to get response?

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
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:

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 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?

So if I want different classes/methods for different operations, do I need to create separate route folder/file for each?

how my composer json should be to download this?

“psx/psx-examples” : “*”

or how?

well I was able to download it with psx/sample and I got everything in my /vendor now I want to see its samples, I did edit configuration.php url to
then I saw in routes when I go to:
I see file not found error for /internet/1
please advice.

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]

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.