thinkphp项目部署到Linux服务器上报错“模板不存在”如何解决,thinkphplinux
thinkphp项目部署到Linux服务器上报错“模板不存在”如何解决,thinkphplinux
最近一个项目部署到Linux服务器上去的时候,发现某些模板竟然会报错说“模板不存在:/Application/Admin/....”
检查了服务器上的文件,并没有缺少文件,再次上传文件到服务器,还是报错。莫名其妙,怀疑是代码问题。
仔细检查后,发现是模板的文件名问题:
用过TP的都知道:thinkphp会在$this->display()的时候,会自动获取方法名作为模板的文件名,比如一个getUserInfo方法对用着getuserinfo.html的模板文件。
对控制器里的方法,我用驼峰命名法,而view层里的模板名,也是用了驼峰命名法。比如getUserInfo方法对应了getUserInfo.html的模板文件,但是!thinkphp在$this->display()的时候,读取方法名作为模板名,读出来的方法名是小写的,也就是要求模板名为getuserinfo.html。
在Windows下不区分文件名大小写,Linux会区分,所以报错了。
解决办法:要么改模板文件名为小写,要么$this->display('模板文件名')(不带.html)。
细节决定成败,希望这篇文章可以真正的帮助大家,谢谢大家的阅读。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Brief introduction to the reason for the http request error: 504GatewayTimeout: During network communication, the client interacts with the server by sending HTTP requests. However, sometimes we may encounter some error messages during the process of sending the request. One of them is the 504GatewayTimeout error. This article will explore the causes and solutions to this error. What is the 504GatewayTimeout error? GatewayTimeo

http request error: Solution to SocketError When making network requests, we often encounter various errors. One of the common problems is SocketError. This error is thrown when our application cannot establish a connection with the server. In this article, we will discuss some common causes and solutions of SocketError. First, we need to understand what Socket is. Socket is a communication protocol that allows applications to

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

If you are learning Python and want to develop GUI applications, PyQt5 is a very good choice. It is a bound version of the PyQt library under Python, which makes it very convenient to call and develop the Qt graphics library. However, sometimes you may encounter some problems when installing PyQt5. This guide will provide you with some steps to quickly solve installation error problems, and also attach specific code examples. Make sure the Python version is correct PyQt5 is a Python-based library, so first

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.
