search

Home  >  Q&A  >  body text

[php] Does PHP have a class library that requests restful interface?

I previously developed a handwritten curl method that supports get and post requests

Now I need to use the put and delete methods. I want to find a class library that is specifically responsible for requests. Is there one? It is best to install it through composer, thank you

ringa_leeringa_lee2725 days ago879

reply all(3)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-06-10 09:49:29

    https://packagist.org/package... This

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-06-10 09:49:29

    guzzle, requests are more commonly used

    reply
    0
  • typecho

    typecho2017-06-10 09:49:29

    A proper REST client for php I have been using this and it is pretty good.

    <?php
    
    $pest = new Pest('http://example.com');
    
    $thing = $pest->get('/things');
    
    $thing = $pest->post('/things', 
        array(
            'name' => "Foo",
            'colour' => "Red"
        )
    );
    
    $thing = $pest->put('/things/15',
        array(
            'colour' => "Blue"
        )
    );
    
    $pest->delete('/things/15');
    
    ?>

    reply
    0
  • Cancelreply