GitHub: https://github.com/chariothy/laravel4-sae
Laravel4-sae
You only need to manually add a line of code to make laravel4 (~ 4.2) It runs on SAES and does not require command switching between local and SAES. It automatically judges the environment and switches the configuration.
Install laravel in SAE
Installing laravel in SAE is slightly different from installing it in a local environment:
- Create an application without code in "Application Management" of SAE, for example, project-Name (this is just an example. In fact, Sae does not allow the use of the character '-');
- Synchronize it to a local directory using SVN. You will see an additional local directory named project-name;
- In the command line window, go to project-name, create a laravel application, and enter
composer create-project laravel/laravel=4.1.* project-version --prefer-dist
! Note that the project-version in the above command should be a number, which is the version number of the SAE application you have never used before. For new applications, it starts from 1. The website root directory in the following example refers to project-name/Project-version.
The PHP version of SAE is 5.3, so it can be up to laravel4.1.x. (Laravel4.2 uses the trait feature of php5.4)
After a long wait, the installation is successful, and then navigate to project-name/Project-version in the CMD window, add the laravel4-sae with composer, enter:
composer require chariothy/laravel4-sae dev-master
It updates composer. JSON under the website root project and installs the laravel4-sae under the vendor directory. Finally, use SVN to upload the entire application to sae. An additional version number is displayed under "code management" of "Application Management". Enable the kvdb service in "kvdb" of "service management.
How to Use
The only line of code to be added is: open app/start/artisan. php under the root directory of the website project, and add
Artisan::add(new Chariothy\SaePatch);
After saving, open the CMD window, go to the root directory of your website project, and enter
php artisan sae
Okay, normally a bunch of successfully output:
- [config] Successfully created folder ‘app/config/sae‘- Successfully backed up ‘app/config/sae/database.php.‘ [db] Successfully added file ‘app/config/sae/database.php.‘.- Successfully backed up ‘app/config/sae/app.php‘ [app] Successfully added file ‘app/config/sae/app.php‘.- Successfully backed up ‘index.sae.php‘ [index] Successfully added file ‘index.sae.php‘.- Successfully backed up ‘config.yaml‘ [yaml] Successfully added file ‘config.yaml‘.- Successfully backed up ‘favicon.ico‘ [favicon] Successfully added file ‘favicon.ico‘.- Successfully backed up ‘bootstrap/start.php‘ [env] Successfully patched ‘detectEnvironment‘ for sae.- Successfully backed up ‘bootstrap/start.php‘ [wrap] Successfully patched ‘wrap storage‘ for sae.- Successfully backed up ‘app/start/global.php‘ [log] Successfully patched ‘SaeDebugHandler‘ for sae.- THE END.
This is all. Now you can use SVN to upload data to sae (do not forget to enable kvdb in SAE first !), Open the homepage and you will see the familiar "You have arrived ."
What have saepatch done?
The output result is explained as follows:
-[Config] A directory named 'app/config/SAE 'is created, which is set in the SAE environment. -Database settings in the [dB] SAE environment. -[App] app settings in the SAE environment. -[Index] Create 'index. Sae. php' in the root directory to meet the requirements of the SAE directory structure. It is not like using public as the root directory locally. -[Yaml] Create 'config. yaml ', which is the rewrite rule of SAE. -[favicon] Create an empty 'favicon in the root directory. ICO, because the SAE directory structure is not as public as the root directory in the local. -[ENV] adds a 'detectenvironment 'in 'bootstrap/start. php' to detect the SAE environment. -[Wrap] add [SAE wrappers] (http://sae.sina.com.cn/doc/php/runtime.html#wrappers "") for the 'store' directory in 'bootstrap/start. php ""). -[Log] add 'saedebughandler' to 'app/start/global. php' to call sae_debug () of SAE ().
-- Overwrite Option
By default, saepatch ignores patches that have already been installed. However, you can overwrite them with -- overwrite to overwrite them. You can overwrite them all or overwrite them. You don't have to worry about it. It will be backed up first. Specific parameters:
Options: --overwrite (-o) Patch laravel4 even it has been patched before. Option value: config Add folder app/config/sae. db Add file app/config/sae/database.php.. app Add file app/config/sae/app.php. index Add file index.sae.php. yaml Add file config.yaml. favicon Add file favicon.ico. env Add closure for $app->detectEnvironment(). wrap Wrap storage path with SAE wrapper prefix. log Add SaeDebugHandler for MonoLog. all overwrite all above. Example1: php artisan sae -o db Example2: php artisan sae -o all
All options
php artisan sae -h
All options are displayed.
Special note
In the SAE environment, if you need to switch memcached, storage, and kvdb, config. cache. drive and config. session. keep the file unchanged in drive. sae. APP (in config/SAE/app. in PHP.
In fact, the storage of SAE does not support file append at least, but memcache is too expensive. Therefore, the default kvdb is used to store the characters, and storage is suitable for storing some static images, memcache is not too late to change when the access traffic goes up.
In addition, do not forget to open kvdb and other related services in the SAE control panel ~
Have fun!
PS: convenience those composer speed too slow friends, I packed a laravel4.1.27 with a laravel4-sae, directly decompress it to upload to sae run, Here download.
You only need to manually add a line of code to run laravel4 in SAE