PHP code example of modera / direct-bundle
1. Go to this page and download the library: Download modera/direct-bundle 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/ */
modera / direct-bundle example snippets
php
// config/bundles.php
return [
// ...
Modera\DirectBundle\ModeraDirectBundle::class => ['all' => true],
];
php
// .../Acme/DemoBundle/Controller/ExampleController.php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Modera\DirectBundle\Annotation\Remote;
use Modera\DirectBundle\Annotation\Form;
class ExampleController extends AbstractController
{
/**
* Single exposed method.
*
* @Remote // this annotation expose the method to API
*
* @param array $params
* @return string
*/
public function indexAction(array $params)
{
return 'Hello ' . $params['name'];
}
/**
* An action to handle forms.
*
* @Remote // this annotation expose the method to API
* @Form // this annotation expose the method to API with formHandler option
*
* @param array $params Form submitted values
* @param array $files Uploaded files like $_FILES
*/
public function testFormAction(array $params, array $files)
{
// your proccessing
return true;
}
}