{"id":13669360,"url":"https://github.com/chariothy/laravel4-sae","last_synced_at":"2025-04-27T02:31:11.378Z","repository":{"id":21917707,"uuid":"25241901","full_name":"chariothy/laravel4-sae","owner":"chariothy","description":"让Laravel4可以无痛地运行在SAE。","archived":false,"fork":false,"pushed_at":"2015-03-19T00:56:00.000Z","size":248,"stargazers_count":11,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-24T07:52:21.883Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chariothy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-15T06:33:05.000Z","updated_at":"2017-08-31T05:02:14.000Z","dependencies_parsed_at":"2022-08-20T02:50:35.645Z","dependency_job_id":null,"html_url":"https://github.com/chariothy/laravel4-sae","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chariothy%2Flaravel4-sae","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chariothy%2Flaravel4-sae/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chariothy%2Flaravel4-sae/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chariothy%2Flaravel4-sae/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chariothy","download_url":"https://codeload.github.com/chariothy/laravel4-sae/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251080017,"owners_count":21533039,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T08:01:10.993Z","updated_at":"2025-04-27T02:31:11.140Z","avatar_url":"https://github.com/chariothy.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"laravel4-sae v1.1.0\n============\n只需手动增加两行代码即可让Laravel4（ \u003c 4.2）运行在SAE，而且在本地和在SAE开发无需命令切换，自动判断环境并切换配置。\n\n## 安装\n\n####在SAE安装Laravel\n在SAE安装Laravel与本地环境安装稍有区别：\n\n1. 在SAE的“应用管理”中新建一个没有代码的应用，比如叫projectname；\n2. 用svn将其同步到本地，你会看到本地多出个目录projectname；\n3. 打开在命令行窗口，定位到projectname，创建一个laravel应用，输入\n\n```\ncomposer create-project laravel/laravel=4.1.* project-version --prefer-dist\n```\n**！注意**上面命令中的project-version，这应该是个数字，是你还没用过的SAE应用的版本号，对新应用来说从1开始。下文中指的网站根目录是指projectname/project-version，切记。\n\n**SAE的php版本为5.3，因此最高只能支持到Laravel4.1.x。（Laravel4.2用到了php5.4的trait特性）**\n\n漫长的等待后安装成功，然后cmd窗口中定位到projectname/project-version，用composer加入laravel4-sae，输入：\n\n```\ncomposer require chariothy/laravel4-sae dev-master\n```\n\n它会更新网站根项目下的composer.json，并将laravel4-sae安装到vendor目录下。\n最后用svn将整个应用上传到SAE，“应用管理”的“代码管理”下就会多出一个版本号，**在“服务管理”的“KVDB”中开启KVDB服务**。\n\n## 如何使用\n\n好了，要增加的两行代码来了：\n打开网站项目根目录下app/config/app.php，找到'providers'设置，在结尾处添加'Chariothy\\SaeServiceProvider'：\n```\n'providers' =\u003e array(\n\n        ......\n        'Chariothy\\SaeServiceProvider',\n\t),\n```\n找到'aliases'设置，在结尾处添加'SAE' =\u003e 'Chariothy\\SaeFacade'：\n```\n'aliases' =\u003e array(\n\n\t\t......\n\n        'SAE' =\u003e 'Chariothy\\SaeFacade',\n\t),\n```\n保存之后，打开cmd窗口，定位到你的网站项目根目录下，输入\n```\nphp artisan sae\n```\n好了，正常情况下会输出一堆Successfully：\n```\n- [config]     Successfully created folder 'app/config/sae'\n-              Successfully backed up 'app/config/sae/database.php.'\n  [db]         Successfully added file 'app/config/sae/database.php.'.\n-              Successfully backed up 'app/config/sae/app.php'\n  [app]        Successfully added file 'app/config/sae/app.php'.\n-              Successfully backed up 'index.sae.php'\n  [index]      Successfully added file 'index.sae.php'.\n-              Successfully backed up 'config.yaml'\n  [yaml]       Successfully added file 'config.yaml'.\n-              Successfully backed up 'favicon.ico'\n  [favicon]    Successfully added file 'favicon.ico'.\n-              Successfully backed up 'bootstrap/start.php'\n  [env]        Successfully patched 'detectEnvironment' for sae.\n-              Successfully backed up 'bootstrap/start.php'\n  [wrap]       Successfully patched 'wrap storage' for sae.\n-              Successfully backed up 'app/start/global.php'\n  [log]        Successfully patched 'SaeDebugHandler' for sae.\n- THE END.\n```\n这就是全部。现在你可以用svn上传到SAE（**不要忘记先在SAE中开启KVDB服务！**），\n打开首页将看到熟悉的“You have arrived.”\n\n## 如何添加静态链接\n在laravel中是用{{HTML::stript('js/code.js')}}、{{HTML::style('css/style.js')}}、{{HTML::image('img/image.png')}}这三句来添加。\n但前提是在本地部署，同时将root/public设置为根目录。而在SAE上，一般会将图片等资源放在storage中。\n这里laravel4-sae在app/config/sae/app.php下添加了几个设置项：\n```\n'sae' =\u003e array(\n        //这是用来设置你的缓存等存放在SAE的KVDB中\n        'wrapper' =\u003e 'saekv://',\n\n\n        //这里是开启storage时设置的domain，具体值自己设置\n        'domain' =\u003e 'example',\n        \n        //这里指定了三种资源的存放位置，值有'code'和'storage'\n        //'code'则放在root/public相应的目录下\n        //'storage'会放在SAE的storage相应的目录下\n        'style'     =\u003e 'code',\n        'script'    =\u003e 'code',\n        'image'     =\u003e 'storage',\n    ),\n```\n这样你在代码中只要用{{SAE::script('js/code.js')}}、{{SAE::style('css/style.js')}}、{{SAE::image('img/image.png')}}这三句即可。\n同时这三句对本地部署同样适用，无需切换。\n\n## SaePatch都做了啥？\n以下对输出的结果做解释：\n```\n- [config]     创建了一个目录 'app/config/sae'，其中是在SAE环境下的设置。\n- [db]         SAE环境下的database设置。\n- [app]        SAE环境下的app设置。\n- [index]      在根目录下创建'index.sae.php'，这是为了满足SAE的目录结构不像在本地时以public为根目录。\n- [yaml]       在根目录下创建'config.yaml'，这是SAE的rewrite规则.\n- [favicon]    在根目录下创建空的'favicon.ico'，因为SAE的目录结构不像在本地时以public为根目录。\n- [env]        在'bootstrap/start.php'增加一个'detectEnvironment'来检测SAE环境。\n- [wrap]       在'bootstrap/start.php'中为'storage'目录添加[SAE wrappers](http://sae.sina.com.cn/doc/php/runtime.html#wrappers \"\")。\n- [log]        在'app/start/global.php'中增加'SaeDebugHandler'来调用SAE的sae_debug()。\n```\n\n## --overwrite选项\n默认情况下SaePatch会忽略掉已经打过的补丁，不过你可以用--overwrite来覆盖它，可以全部覆盖，也可以选择覆盖。不用担心，都会先备份的。具体参数：\n```\nOptions:\n --overwrite (-o)      Patch laravel4 even it has been patched before.\n\n                       Option value:\n                       config   Add folder app/config/sae.\n                       db       Add file app/config/sae/database.php..\n                       app      Add file app/config/sae/app.php.\n                       index    Add file index.sae.php.\n                       yaml     Add file config.yaml.\n                       favicon  Add file favicon.ico.\n                       env      Add closure for $app-\u003edetectEnvironment().\n                       wrap     Wrap storage path with SAE wrapper prefix.\n                       log      Add SaeDebugHandler for MonoLog.\n                       all      overwrite all above.\n\n                       Example1: php artisan sae -o db\n                       Example2: php artisan sae -o all\n```\n\n## 所有选项\n```\nphp artisan sae -h\n```\n可以看到所有选项\n\n## 使用示例\n见HOW-TO.MD\n\n## 特别注意\n在SAE环境下，如需切换memcached、storage、kvdb，则config.cache.drive和config.session.drive均保持file不变，只需在config.sae.app（在config/sae/app.php中）中改变wrapper属性即可。\n\n事实上，SAE的storage至少目前不支持文件append，而memcache又太贵，所以就用默认的kvdb来保存字符挺好的，storage还是适合放些静态图片等等，memcache等着访问量上去了再换也不迟。\n\n另外，**可别忘了在SAE的控制面板中打开kvdb等相应的服务哦~**\n\nHave fun!\n\n**PS: 为了方便那些composer速度太慢的朋友，我用laravel4-sae打包了一个laravel 4.1.27，直接解压出来就可以上传到SAE运行，[这里下载](http://download.csdn.net/detail/thy38/8170417)。**\n\n## 更新日志\nv 1.1.0 \n提供对静态资源在storage的支持，感谢flyboy\n\nv 1.0.0 初始版本\n通过sae命令可以对laravel打上sae补丁\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchariothy%2Flaravel4-sae","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchariothy%2Flaravel4-sae","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchariothy%2Flaravel4-sae/lists"}