1. Go to this page and download the library: Download aidan-casey/http-parser 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/ */
aidan-casey / http-parser example snippets
// Provides composer dependencies.
pp([
'settings' => [
'displayErrorDetails' => true
]
]);
// Add a database connection to our application container.
$Container = $App->getContainer();
$Container['DB'] = function ( $Container )
{
// Setup our query adapter.
$Adapter = new Zend\Db\Adapter\Adapter([
'database' => 'Example',
'driver' => 'Mysqli',
'host' => 'localhost',
'password' => '',
'username' => 'ExampleUser'
]);
// Now setup our sql object.
return new Zend\Db\Sql\Sql( $Adapter );
};
// Setup our API route.
$App->get('/', function ( $Request, $Response ) use ( $Container )
{
// Parse any filters, etc.
$Parser = new AidanCasey\HttpParser\HttpToZend();
$Select = $Parser->ConvertHttpRequest( $Request );
// Prepare a query for the database.
$Statement = $Container['DB']->prepareStatementForSqlObject(
$Select->from('ExampleTable')
);
// Now execute that query.
$Result = $Statement->execute();
});
// Run our Slim app.
$App->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.