PHP code example of zenstruck / redirect-bundle
1. Go to this page and download the library: Download zenstruck/redirect-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/ */
zenstruck / redirect-bundle example snippets
// config/bundles.php
return [
// ...
Zenstruck\RedirectBundle\ZenstruckRedirectBundle::class => ['all' => true],
];
namespace App\Entity;
use Zenstruck\RedirectBundle\Model\Redirect as BaseRedirect;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="redirects")
*/
class Redirect extends BaseRedirect
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
}
namespace App\Entity;
use Zenstruck\RedirectBundle\Model\NotFound as BaseNotFound;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="not_founds")
*/
class NotFound extends BaseNotFound
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
}
$redirect = // ...
$form = $this->createForm('zenstruck_redirect', $redirect);
// new action
$redirect = new Redirect();
$form = $this->createForm('zenstruck_redirect', $redirect);
// edit action
$redirect = // get from database
$form = $this->createForm('zenstruck_redirect', $redirect, array('disable_source' => true));