This article gives an example of how thinkphp is deployed in the Sina SAE platform. Share to everyone for your reference. The implementation methods are as follows:
Thinkphp has provided SAE platform support since the thinkphp3.0 version and has many features that support localization development and commissioning and deployment switching, allowing Thinkphper to easily transition to SAE development.
First, the preparatory work:
1, you need to have SAE account number, if you do not have this account, please go to SAE official website application.
2, the development of their own or to find a program based on thinkphp3.12 development, this test using the blog program WBlog3.1.3 version, no can click here to download this site.
3, to thinkphp official network download 3.12 version of the SAE engine Engine, and put it into the core package expansion package, SAE engine in the thinkphp package location: Thinkphp\extend\engine
Second, the realization steps:
1, create an application, HTTP://127.0.0.1/as shown in the picture:
2, create a version, here I clay 1, as shown in the figure:
3, upload code package, complete upload code package as shown in the picture:
4, create the database. The path to open the database is w3note»mysql» service Management» Managing MySQL, the database name I created is Wblog, and then importing the datasheet SQL file
5, the configuration before and after the project entry file, the method is similar. The following is the foreground item portal file index.php configuration
Copy Code code as follows:
<?php
Turn on debug mode
Define (' App_debug ', true);
Front Directory
Define (' App_path ', './w3note/');
Define (' W3core_path ', './thinkphp ');
Require W3core_path. ' /extend/engine/sae.php ';//loading Sae engine files
6. Database File Configuration
After the database has been built, the configuration of the database files, such as Db_host, Db_user, Db_pwd, and Db_name, appears to be generic
Copy Code code as follows:
<?php
// +----------------------------------------------------------------------
// | Wblog
// +----------------------------------------------------------------------
// | Copyright (c) 2008 http://www.w3note.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed (http://www.apache.org/licenses/LICENSE-2.0)
// +----------------------------------------------------------------------
// | Author: Net pineapple Fruit
// +----------------------------------------------------------------------
$Id $
if (!defined (' W3core_path ')) exit ();
Return Array (
' Db_type ' => ' MySQL ',
' Db_host ' =>sae_mysql_host_m,
' Db_user ' =>sae_mysql_user,
' Db_pwd ' =>sae_mysql_pass,
' Db_name ' =>sae_mysql_db,
' Db_prefix ' => ' wb_ ',
' Rbac_role_table ' => ' wb_role ',
' Rbac_user_table ' => ' Wb_role_user ',
' Rbac_access_table ' => ' wb_access ',
' Rbac_node_table ' => ' Wb_node ',
' KeyCode ' => ' gfgp5o ',
);
?>
It seems to have been done here, but note the following two points.
1, SAE strict case sensitivity
If the CSS in the path http://127.0.0.1/Public/Css/style.css changes to a CSS style file, it loads the error. However, there is no error in the local test.
2, SAE URL routing hidden index.php
If you hide index.php in a local URL such as Http://127.0.0.1/WBlog/blog, you cannot access it in the SAE. Reason is
The SAE does not support. htaccess files, but we can use the AppConfig service provided by the SAE to implement pseudo static.
In your project's root directory Config.yaml file (usually automatically generated, not built yourself), plus the following code:
Handle
-Rewrite:if (!is_dir () &&!is_file () && path~ "^ (. *) $") goto "index.php/$1"
So we can hide the entrance.
I hope this article will be helpful to everyone's thinkphp framework program design.