Deploy thinkphp 5.0 RC4 on the SAE

Source: Internet
Author: User

Origin

SAE and other platforms are somewhat different, can not run Composer on the server to install a variety of packages, the source must be submitted up. As a general practice, it is possible to copy all files of source code directly into the directory and add them to the repository. However, this loses the advantage of synchronizing with the upstream code. Fortunately, Git provides another feature called subtree, which not only provides version tracking functionality, but also allows the code to be synchronized with the upstream, while the source file can be submitted to the current repository.

Process

First of all, of course, the subtree command to install git. This command, although installed with Git, is not enabled by default. Each platform has different installation methods, please search for the installation yourself.

The second step is to add the think and the framework to the remote repository:

1 git remote add-f think https://github.com/top-think/think2 git remote add-f frame Work https://github.com/top-think/framework

In this way, two repo are added to the local, and fetch down. Create an empty project below and initialize it with Git. Remember to submit at least once.

1 mkdir Demo 2 CD Demo 3 git init 4 Touch readme.md 5 git Add. 6 " First commit. "

The point is to bind repo to the directory with subtree.

git subtree add--prefix tp5 think master----prefix tp5/thinkphp Framework Master--squash

Above this is the key step. After the completion, the basic thinkphp 5 framework is well done. However, the default thinkphp 5 needs to be written to a local file, which is not allowed on the SAE. Fortunately the thinkphp team offers the SAE extension: https://github.com/top-think/think-sae. It's not perfect here. The default package is provided by composer, but we cannot use composer to install it here. After studying the autoload mechanism of thinkphp 5, I found that he provided a PSR-4 loading mechanism. It is necessary to copy the three PHP files from the src directory of the SAE extension to tp5/thinkphp/library/think/sae. Here SAE this directory is not present and needs to be created by itself. Because I did not read the thinkphp 5 source code, so I did not find how to configure the way PSR-4 load path. Therefore, only these three files cannot be synchronized with upstream. The SAE extension requires some configuration, please refer to the extension's homepage. However, in order for the thinkphp to run in a non-SAE environment, some configuration files need to be set up. The first is to define a constant in public/index.php to identify whether it is in the SAE environment:

1 Define defined ("Sae_mysql_user"));

Then in the configuration file, you can do this:

1 ' log ' =[2     ' type ' = ' in_sae? ' \think\sae\log ': ' File ',3 ]

Similarly, each configuration is distinguished as a local configuration and an SAE environment configuration.

Then, follow the SAE instructions and push the code onto the SAE.

Update Upstream code:

--prefix TP5 Think Master----prefix tp5/thinkphp framekwork Master--squash

In this way, you can happily play on the SAE thinkphp 5.

Deploy thinkphp 5.0 RC4 on the SAE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.