1. Go to this page and download the library: Download 360i/sonno library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
360i / sonno example snippets
php
namespace Sonno\Example\Resource;
use Sonno\Http\Response\Response,
Sonno\Annotation\Path,
Sonno\Annotation\GET,
Sonno\Annotation\POST,
Sonno\Annotation\Context,
Sonno\Annotation\Produces,
Sonno\Annotation\Consumes,
Sonno\Annotation\PathParam,
Sonno\Example\Representation\User\Collection as UserCollection;
/**
* @Path("/")
*/
class HelloResource
{
/**
* @Context("Request")
*/
protected $_request;
/**
* @GET
* @Produces({"text/plain"})
*/
public function getHelloWorld()
{
return 'Hello ReSTful World!';
}
/**
* @GET
* @Path("/users")
* @Produces({"application/xml"})
*/
public function getUserCollection()
{
return new UserCollection('application/xml');
}
/**
* @POST
* @Path("/users")
* @Consumes({"application/xml"})
*/
public function saveUserXml()
{
// Retrieve the request body.
$data = $this->_request->getRequestBody();
// ... Do some processing of $data, then save it...
$response = new Response();
return $response->setCreated('http://example.sonno.dev/users/10');
}
}
php
use Sonno\Configuration\Driver\AnnotationDriver,
Sonno\Annotation\Reader\DoctrineReader,
Doctrine\Common\Annotations\AnnotationReader,
Doctrine\Common\Annotations\AnnotationRegistry;
$doctrineReader = new AnnotationReader();
AnnotationRegistry::registerAutoloadNamespace(
'Sonno\Annotation',
realpath('path/to/Sonno/src')
);
$annotationReader = new DoctrineReader($doctrineReader);
$resources = array(
'FQNS\To\SomeResource',
'FQNS\To\SomeOtherResource',
);
$driver = new AnnotationDriver($resources, $annotationReader);
$config = $driver->parseConfig();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.