Reputation: 1793
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
Upvotes: 3
Views: 4554
Reputation: 3697
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.
Upvotes: 3
Reputation: 836
You should do package installation with composer for PHP Engine. Try cleaning the cache. Check the permissions (755 or 777) of the "Templates" directory.
http://symfony.com/doc/master/templating/PHP.html
Upvotes: 0