Home > PHP Framework > Laravel > How to change template suffix in laravel

How to change template suffix in laravel

PHPz
Release: 2023-03-31 17:22:01
Original
654 people have browsed it

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.

Step one: Modify the config/view.php file

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',
],
Copy after login

Step 2: Modify the file suffix of the view file

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
Copy after login

Step 3 (optional): Modify the view return function in the controller

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');
Copy after login

We need to modify it to:

return view('welcome.html');
Copy after login

Summary

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template