PHP code example of mmoreram / controller-extra-bundle
1. Go to this page and download the library: Download mmoreram/controller-extra-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/ */
mmoreram / controller-extra-bundle example snippets
php
/**
* Simple controller method
*
* @SomeAnnotation(
* class = "Mmoreram\CustomBundle\Entity\MyEntity",
* )
*/
public function indexAction()
{
}
php
/**
* Simple controller method
*
* @SomeAnnotation(
* class = "MmoreramCustomBundle:MyEntity",
* )
*/
public function indexAction()
{
}
php
/**
* Simple controller method
*
* @SomeAnnotation(
* class = "my.bundle.entity.myentity",
* )
*/
public function indexAction()
{
}
php
use Doctrine\ORM\Tools\Pagination\Pagination;
use Mmoreram\ControllerExtraBundle\Annotation\CreatePaginator;
/**
* Simple controller method
*
* @CreatePaginator(
* entityNamespace = "MmoreramCustomBundle:User",
* )
*/
public function indexAction(Paginator $paginator)
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\CreateForm;
use Symfony\Component\Form\AbstractType;
/**
* Simple controller method
*
* @CreateForm(
* class = "\Mmoreram\CustomBundle\Form\Type\UserType",
* name = "userType"
* )
*/
public function indexAction(AbstractType $userType)
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\CreateForm;
use Symfony\Component\Form\AbstractType;
/**
* Simple controller method
*
* @CreateForm(
* class = "user_type",
* name = "userType"
* )
*/
public function indexAction(AbstractType $userType)
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\CreateForm;
use Symfony\Component\Form\Form;
/**
* Simple controller method
*
* @CreateForm(
* class = "user_type",
* name = "userForm"
* )
*/
public function indexAction(Form $userForm)
{
}
php
use Symfony\Component\Form\FormView;
use Mmoreram\ControllerExtraBundle\Annotation\CreateForm;
/**
* Simple controller method
*
* @CreateForm(
* class = "user_type",
* name = "userFormView"
* )
*/
public function indexAction(FormView $userFormView)
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Flush;
/**
* Simple controller method
*
* @Flush
*/
public function indexAction()
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Flush;
/**
* Simple controller method
*
* @Flush(
* manager = "my_own_manager"
* )
*/
public function indexAction()
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\ToJsonResponse;
/**
* Simple controller method
*
* @ToJsonResponse
*/
public function indexAction(User $user, Address $address)
{
return array(
'This is my response'
);
}
php
use Mmoreram\ControllerExtraBundle\Annotation\ToJsonResponse;
/**
* Simple controller method
*
* @ToJsonResponse(
* status = 403,
* headers = {
* "User-Agent": "Googlebot/2.1"
* }
* )
*/
public function indexAction(User $user, Address $address)
{
return array(
'This is my response'
);
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Log;
/**
* Simple controller method
*
* @Log("Executing index Action")
*/
public function indexAction()
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Log;
/**
* Simple controller method
*
* @Log(
* value = "Executing index Action",
* level = @Log::LVL_WARNING
* )
*/
public function indexAction()
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Log;
/**
* Simple controller method
*
* @Log(
* value = "Executing index Action",
* execute = @Log::EXEC_POST
* )
*/
public function indexAction()
{
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Get;
/**
* Simple controller method
*
* @Get(
* path = "foo"
* )
*/
public function indexAction($foo)
{
// Use the foo var
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Get;
/**
* Simple controller method
*
* @Get(
* path = "foo",
* name = "varName",
* default = 'bar',
* )
*/
public function indexAction($varName)
{
// This would print 'bar'
echo $varName;
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Post;
/**
* Simple controller method
*
* @Post(
* path = "foo"
* )
*/
public function indexAction($foo)
{
// Use the foo var
}
php
use Mmoreram\ControllerExtraBundle\Annotation\Post;
/**
* Simple controller method
*
* @Post(
* path = "foo",
* name = "varName",
* default = 'bar',
* )
*/
public function indexAction($varName)
{
// This would print 'bar'
echo $varName;
}
php
namespace My\Bundle\Annotation;
use Mmoreram\ControllerExtraBundle\Annotation\Annotation;
/**
* Entity annotation driver
*
* @Annotation
* @Target({"METHOD"})
*/
final class MyCustomAnnotation extends Annotation
{
/**
* @var string
*
* Dummy field
*/
public $field;
/**
* Get Dummy field
*
* @return string Dummy field
*/
public function getField()
{
return $this->field;
}
}
php
namespace My\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Doctrine\Common\Annotations\AnnotationRegistry;
/**
* MyBundle
*/
class ControllerExtraBundle extends Bundle
{
/**
* Boots the Bundle.
*/
public function boot()
{
$kernel = $this->container->get('kernel');
AnnotationRegistry::registerFile($kernel
->locateResource("@MyBundle/Annotation/MyCustomAnnotation.php")
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.