Home > Article > PHP Framework > How to change template suffix in laravel
Laravel is a popular PHP web application framework based on the MVC pattern and provides many useful features and tools to help developers quickly develop high-quality web applications. In the development of Laravel applications, developers often need to modify the framework's default template suffix. So, how to change the template suffix in Laravel? Let’s introduce it step by step.
In the root directory of the Laravel application, find the config directory and find the view.php file in this directory. This file defines the view engine configuration items for the Laravel application. We need to modify the 'blade.php' string in the 'extensions' array in this file to the template suffix we need, such as 'html' or 'tpl', etc. An example is as follows:
'extensions' => [ 'html', ],
In the view file directory of the Laravel application, usually under the resources/views directory, we need to add all views The suffix of the file is changed to the template suffix configured in the first step, otherwise Laravel will not be able to load the view file correctly. An example is as follows:
welcome.html
In the controller of the Laravel application, we often use the view return function to pass data Give the view file, such as:
return view('welcome');
We need to modify it to:
return view('welcome.html');
Through the above three steps, we can successfully modify the template suffix of the Laravel application . It is worth noting that after modifying the template suffix, we need to ensure that the suffixes of all view files are also modified, otherwise the view files will not be loaded correctly.
The above is the detailed content of How to change template suffix in laravel. For more information, please follow other related articles on the PHP Chinese website!