Api-php write restful interface?

Source: Internet
Author: User
Tags php write
I want to use php to implement a simple restfullapi and find that php is not as easy to control routing rules as nodejs. The routing is controlled by apache and can give some suggestions. How can I control the routing to implement restfulapi? I want to use php to implement a simple restfull api
It is found that php is not as easy to control routing rules as nodejs. The routes are controlled by apache.

Can you give me some suggestions? How do I control routes to implement restful APIs?

Reply content:

I want to use php to implement a simple restfull api
It is found that php is not as easy to control routing rules as nodejs. The routes are controlled by apache.

Can you give me some suggestions? How do I control routes to implement restful APIs?

Http://frapi.github.io/developing/creati... generate api interface directly with the background

No route is required to be handed over to Apache! You can aggregate all requests to a unified portal, parse the request URI and Method, and schedule the requests to the corresponding Api program. In the same way, you can implement Restful interfaces. Many PHP frameworks are specially developed for Restful, such as Slim. In addition, most PHP frameworks support Restful routing. You can see their code for specific implementations.

Yii/Laravel framework

You can use this redirection rule to forward files that cannot be found to index. php.

Options +FollowSymLinksRewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php [L]

Then you can define your own Routes.

If you try laravel, you will find it is very similar to express. laravel is recommended.

What you need is a php route controller, and slim is really good.

All the frameworks can customize the routes. For example, ci and thinkphp only bind the routes to the corresponding controllers by default.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.