第一次使用TP5.0新建項目
僅供參考。
安裝問題中所屬:新建一個項目,下屬:shop,cms,weixin,mobile四個模塊(這里暫時稱之為模塊吧)
一、將你的網(wǎng)站住目錄設(shè)置為 ./public
也就是說,你的網(wǎng)站主目錄是public目錄,github中的其他兩個目錄隨意你放到任何位置,但是前提是,根據(jù)文件引用規(guī)則,確實能夠相互引用。
public中默認(rèn)有:├─public????????????????WEB目錄(對外訪問目錄)<br>│??├─index.php??????????入口文件<br>│??├─.htaccess??????????用于apache的重寫<br>│??└─router.php?????????快速測試文件(用于PHP內(nèi)置webserver)
這也就意味著,在tp5.0的版本中,你的網(wǎng)站主目錄里將不會出現(xiàn)框架目錄和項目目錄(這樣說可能略顯復(fù)雜了,也就是說:把所有不用直接訪問的文件都移到網(wǎng)站目錄外面了,這樣為了安全。)。
虛擬主機(jī)或者不支持自定義主目錄的云主機(jī)中,請將本目錄里所有文件復(fù)制到外面的主目錄中,并修改相應(yīng)的引用。
也就是tp3.0的方式,否則:你只能使用:http://think.com/public/index.php來訪問了。
二、項目文件的自動生成
從github上clone的時候,默認(rèn)項目目錄中是有文件的,安裝問題中所述,是不想要index這個模塊的,所以可以把a(bǔ)pplication目錄里的文件全部刪除(你最好不要刪除這個目錄)。
然后,復(fù)制github庫中的‘build.php’到‘a(chǎn)pplication’
并修改為:
<?php return [ // 生成運行時目錄 '__dir__' => ['runtime/cache', 'runtime/log', 'runtime/temp'], '__file__' => ['tags.php'], //其實,如果上面的改成:'__file__' => ['tags.php','config.php'], 那么config.php 也會自動創(chuàng)建 // 定義shop模塊的自動生成 'shop' => [ '__file__' => ['tags.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'], 'controller' => ['Index', 'Test', 'UserType'], 'model' => [], 'view' => ['index/index'], ], // 定義cms模塊的自動生成 'cms' => [ '__file__' => ['tags.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'], 'controller' => ['Index', 'Test', 'UserType'], 'model' => [], 'view' => ['index/index'], ], // 定義mobile模塊的自動生成 'mobile' => [ '__file__' => ['tags.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'], 'controller' => ['Index', 'Test', 'UserType'], 'model' => [], 'view' => ['index/index'], ], // 定義weixin模塊的自動生成 'weixin' => [ '__file__' => ['tags.php'], '__dir__' => ['behavior', 'controller', 'model', 'view'], 'controller' => ['Index', 'Test', 'UserType'], 'model' => [], 'view' => ['index/index'], ], // 。。。 其他更多的模塊定義 ];
當(dāng)然,你還要在'index.php'中添加一行代碼:
//你最好在完成自動生成后,把他刪除了。<br/>define('APP_AUTO_BUILD',true);
接著,訪問你的域名(或者本地地址),按照上面問題中所屬的模塊,你會得到一個錯誤頁面
原因很簡單,因為默認(rèn)模塊是index,而這個問題所要求的項目中沒有index模塊。
那么我們要修改配置文件,不過打開項目目錄(application),然后進(jìn)入模塊目錄,你會發(fā)現(xiàn),哦,你找不到配置文件,是的,根據(jù)默認(rèn)的生成情況來看,配置文件是沒有進(jìn)行生成的(最起碼上面的自動生成代碼中是沒有的)。
那么我們可以自己新建一個,根據(jù)tp5.0模板中的介紹,我們可以在項目目錄(application)中直接新建一個’config.php‘文件,并寫入:
<? return [ // 默認(rèn)模塊名 'default_module' => 'shop', // 禁止訪問模塊 'deny_module_list' => [COMMON_MODULE, 'runtime'], // 默認(rèn)控制器名 'default_controller' => 'Index', // 默認(rèn)操作名 'default_action' => 'index', // 默認(rèn)的空控制器名 'empty_controller' => 'Error', // 操作方法后綴 'action_suffix' => '', // 操作綁定到類 'action_bind_class' => false, ];
哦,好吧,從這里你會看出,這里是直接復(fù)制的’think/thinkphp/convention.php‘中的代碼,是的,我想告訴你的就是,如果你遇到問題,直接看tp的源代碼,將會獲得意想不到的幫助。
哦,是的,ThinkPHP 5 簡明開發(fā)手冊 也是個好地方

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

"Go Language Programming Examples: Code Examples in Web Development" With the rapid development of the Internet, Web development has become an indispensable part of various industries. As a programming language with powerful functions and superior performance, Go language is increasingly favored by developers in web development. This article will introduce how to use Go language for Web development through specific code examples, so that readers can better understand and use Go language to build their own Web applications. 1. Simple HTTP Server First, let’s start with a

Huawei Cloud Edge Computing Interconnection Guide: Java Code Samples to Quickly Implement Interfaces With the rapid development of IoT technology and the rise of edge computing, more and more enterprises are beginning to pay attention to the application of edge computing. Huawei Cloud provides edge computing services, providing enterprises with highly reliable computing resources and a convenient development environment, making edge computing applications easier to implement. This article will introduce how to quickly implement the Huawei Cloud edge computing interface through Java code. First, we need to prepare the development environment. Make sure you have the Java Development Kit installed (

The simplest code example of Java bubble sort Bubble sort is a common sorting algorithm. Its basic idea is to gradually adjust the sequence to be sorted into an ordered sequence through the comparison and exchange of adjacent elements. Here is a simple Java code example that demonstrates how to implement bubble sort: publicclassBubbleSort{publicstaticvoidbubbleSort(int[]arr){int

Learn about Python programming with introductory code examples Python is an easy-to-learn, yet powerful programming language. For beginners, it is very important to understand the introductory code examples of Python programming. This article will provide you with some concrete code examples to help you get started quickly. Print HelloWorldprint("HelloWorld") This is the simplest code example in Python. The print() function is used to output the specified content

PHP variables store values ??during program runtime and are crucial for building dynamic and interactive WEB applications. This article takes an in-depth look at PHP variables and shows them in action with 10 real-life examples. 1. Store user input $username=$_POST["username"];$passWord=$_POST["password"]; This example extracts the username and password from the form submission and stores them in variables for further processing. 2. Set the configuration value $database_host="localhost";$database_username="username";$database_pa

How to use PHP to write the inventory management function code in the inventory management system. Inventory management is an indispensable part of many enterprises. For companies with multiple warehouses, the inventory management function is particularly important. By properly managing and tracking inventory, companies can allocate inventory between different warehouses, optimize operating costs, and improve collaboration efficiency. This article will introduce how to use PHP to write code for inventory warehouse management functions, and provide you with relevant code examples. 1. Establish the database before starting to write the code for the inventory warehouse management function.

Title: From Beginner to Mastery: Code Implementation of Commonly Used Data Structures in Go Language Data structures play a vital role in programming and are the basis of programming. In the Go language, there are many commonly used data structures, and mastering the implementation of these data structures is crucial to becoming a good programmer. This article will introduce the commonly used data structures in the Go language and give corresponding code examples to help readers from getting started to becoming proficient in these data structures. 1. Array Array is a basic data structure, a group of the same type

Java Selection Sorting Method Code Writing Guide and Examples Selection sorting is a simple and intuitive sorting algorithm. The idea is to select the smallest (or largest) element from the unsorted elements each time and exchange it until all elements are sorted. This article will provide a code writing guide for selection sorting, and attach specific Java sample code. Algorithm Principle The basic principle of selection sort is to divide the array to be sorted into two parts, sorted and unsorted. Each time, the smallest (or largest) element is selected from the unsorted part and placed at the end of the sorted part. Repeat the above
