Please help, symfony 4 cant find php template.
The error is The template "::test/index.html.php" does not exist.
Controller :
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
class TestController extends Controller
{
public function number()
{
$number = mt_rand(0, 100);
// return new Response(
// '<html><body>Lucky number: '.$number.'</body></html>'
// );
return $this->render("test/number.html.php",
array('number' => $number));
}
function index() {
return $this->render("test/index.html.php");
}
}
Directories:
Thanks
The shortcuts with the bundle:directory:filename notation is not used anymore in Symfony 4. Instead use real path's relative to the templates directory or for bundles use the syntax with the @ prefix. For more information: http://symfony.com/doc/current/templating.html#template-naming-and-locations
If your error occurs from a third party bundle then this bundle is not ready to work with Symfony 4. You could then fork the bundle and change the template notation in the controllers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With