Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Creating random articles
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
use App\Entity\Article;
class ArticleController extends Controller
* @Route("/random-article", name="create_random_article")
public function createRandomArticle()
$article = new Article();
$title = bin2hex(openssl_random_pseudo_bytes(3)); // Titolo random
$article->setContent("Un altro articolo inutile");
$now = new \DateTime();
$em = $this->getDoctrine()->getManager();
return $this->render('article.html.twig', [
'$article' => $article,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.