1. Go to this page and download the library: Download domexx/ares 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/ */
domexx / ares example snippets
namespace Ares\CustomModule\Controller;
use Ares\Framework\Controller\BaseController;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
* Class Controller
*
* @package Ares\CustomModule\Controller
*/
class Controller extends BaseController
{
/**
* Reveals a custom response to the user
*
* @param Request $request The current incoming Request
* @param Response $response The current Response
*
* @return Response Returns a Response with the given Data
*/
public function customResponse(Request $request, Response $response): Response
{
/** @var string $customResponse */
$customResponse = 'your custom response';
return $this->respond(
$response,
response()
->setData($customResponse)
);
}
}
return function (App $app) {
// Registers our custom routes that calls the customResponse function in our custom controller
$app->get('/custom', \Ares\CustomModule\Controller\Controller::class . ':customResponse');
};
namespace Ares\CustomModule\Provider;
use Ares\CustomModule\Model\Custom;
use League\Container\ServiceProvider\AbstractServiceProvider;
/**
* Class CustomServiceProvider
*
* @package Ares\CustomModule\Provider
*/
class CustomServiceProvider extends AbstractServiceProvider
{
/**
* @var array
*/
protected $provides = [
Custom::class
];
/**
* Registers new service.
*/
public function register()
{
$container = $this->getContainer();
$container->add(Custom::class, function () {
return new Custom();
});
}
}
// Adds our CustomProvider to add Customs
$container->addServiceProvider(
new \Ares\CustomModule\Provider\CustomServiceProvider()
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.