PHP code example of bauer01 / unimapper-nette

1. Go to this page and download the library: Download bauer01/unimapper-nette 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/ */

    

bauer01 / unimapper-nette example snippets


UniMapper\Nette\Extension::register($configurator);

return $configurator->createContainer();

namespace YourApp\ApiModule\Presenter;

class EntityPresenter extends \UniMapper\Nette\Api\Presenter
{
    ...
}

namespace YourApp\ApiModule\Presenter;

class EntityPresenter extends \UniMapper\Nette\Api\Presenter
{
    public function actionYourCustomMethod($id)
    {
        ...
    }
}

class SomeRepository extends \UniMapper\Repository
{
    private $requestFactory;

    public function __construct(
        \UniMapper\Connection $connection,
        \UniMapper\Nette\Api\ICustomRequestFactory $requestFactory
    ) {
        parent::__construct($connection);
        $this->requestFactory;
    }

    public function getSomethingFromApi()
    {
        $this->requestFactory()->setResource("apiResource")->setAction("custom")->send();
    }
}
yml
unimapper:
    adapters:
        Mongo: @service
        MySQL: @anotherService
        ...
    cache: true
    namingConvention:
        entity: 'YourApp\Model\*'
        repository: 'YourApp\Repository\*Repository'
    api:
        enabled: false
        module: "Api"
        route: true
    panel:
        enabled: true
        ajax: true # log queries in AJAX requests
    profiler: true
    customQueries:
        - CustomQueryClass
        - ...