Implement RESTFUL webservice with php

I need some understanding on how to implement REST services using php

From what I read sofar, they say "use logical addresses" and it is preferable not to use get variables at all.

I do not see how this URL is processed. Like www.somename.com/product , and the product must not be a physical address.

I mean, you need some kind of input file with php processing code which does the real job, doesn't it?

How it works?

After that, I can repeat the data back between the custom xml tags, and the client application can analyze this. This part that I still remember from working with ajax. Only with REST do you put all resources (data or pieces of data) into a URL.

So this brings me back to my original question. How is this logical url progressing? (within php)

Thanks Richard

+3
source share
2 answers

The main answer is what someone mentioned in the comments above: mod_rewrite . By configuring Apache to use mod_rewrite to route your web requests, you can request all resource requests through a single entry point. Example:

RewriteEngine On
RewriteRule !\.(js|ico|gif|jpg|png|css|html|swf|mp3|wav)$ index.php [L]

index.php. index.php , , $_SERVER['SCRIPT_URI'] , /animals/cat.

MVC .

+2

IMO, - RESTful PHP , RESTful-ness. CakePHP CodeIgniter (, , Symfony, ) REST... , , , . Cake CI, CI.

.htaccess mod_rewrite, Apache, .

0

Source: https://habr.com/ru/post/1713242/


All Articles