查看“Laravel”的源代码
←
Laravel
跳转至:
导航
、
搜索
因为以下原因,你没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看并复制此页面的源代码:
=目录= <div id="indexContent"> [[入门教程]] [[基本功能]] [[系统架构]] [[系统服务]] </div> =起步= ==安装== # 下载Laravel一键安装包。 # 配置Web服务器虚拟主机。 # 将网站根目录配置为laravel5/public。 # 能显示Laravel文字,说明安装成功。 =Homestead= https://phphub.org/topics/2 Laravel 的 Homestead 开发环境部署 这是两年前的旧文了,不知现在是否还有效。 设置数据库连接 本机连接 vm 里 mysql 方法是: host: 127.0.0.1 port: 33060 user: homestead pass: secret ==Is Laravel really this slow?== http://stackoverflow.com/questions/23283574/is-laravel-really-this-slow I just started using Laravel. I've barely written any code yet, but my pages are taking nearly a second to load! ;Reply 1 Laravel is not actually that slow. 500-1000ms is absurd; I got it down to 20ms in debug mode. The problem was Vagrant/VirtualBox + shared folders. I didn't realize they incurred such a performance hit. I guess because Laravel has so many dependencies (loads ~280 files) and each of those file reads is slow, it adds up really quick. kreeves pointed me in the right direction, this blog post describes a new feature in Vagrant 1.5 that lets you rsync your files into the VM rather than using a shared folder. There's no native rsync client on Windows, so you'll have to use cygwin. Install it, and make sure to check off Net/rsync. Add C:\cygwin64\bin to your paths. ;Reply 2 From my Hello World contest, Which one is Laravel? I think you can guess. I used docker container for the test and here is the results To make http-response "Hello World": Golang with log handler stdout : 6000 rps SpringBoot with Log Handler stdout: 3600 rps Laravel 5 with off log :230 rps ==Mac安装== http://laravel-china.org/docs/5.1/homestead 按开发文档步骤安装,比较顺利。 # 安装Virtual Box # 安装Vagrant # 下载本地Lavravl项目代码 # 配置Homestead.yaml # vagrant up # vagrant reload --provision # vagrant destroy --force ==Windows安装== windows的安装步骤与Mac一样,只是电脑配置差异,有些问题要特别处理。 ;在BIOS中,开启虚拟化。 安装好Virtual Box、Vagrant,配置好Homestead.yaml后,vagrant up启动到一半不动了,直到超时退出。 ;在配置文件夹和站点目录 folders的map和to,配置反了,启动时vagrant找不到github_projets目录。 <source lang='text'> folders: - map: d:/github_projects to: /home/github_projects sites: - map: laravel.example.com to: /home/github_projects/LaravelExample/public </source> ;运行composer install 正常启动Vagrant后,打开站点首页,报错,指示vendor目录下的文件找不到。 ;.ssh帐户可以注释掉 <source lang='text'> authorize: ~/.ssh/id_rsa.pub keys: - ~/.ssh/id_rsa </source> ;cpus设置 i5CPU,双核四线程,跑了个负载。 <source lang='bash'> ab -c 50 -n 2000 http://laravel.example.com/ cpus: 1 75.99 72.95 cpus: 2 111.95 114.54 cpus: 3 111.27 115.85 cpus: 4 92.57 95.45 </source> 从测试结果上看,cpus设为2运行效率最高。 =Swagger-php= =SwaggerLume= https://github.com/DarkaOnLine/SwaggerLume 一、安装swagger包 <source lang='bash'> composer require "darkaonline/swagger-lume 1.*" </source> 二、为swagger配置lumen <source lang='php'> // bootstrap/app.php $app->withFacades(); // add this line before Register Container Bindings section: $app->configure('swagger-lume'); // add this line in Register Service Providers section: $app->register(\SwaggerLume\ServiceProvider::class); </source> 三、配置及生成swagger <source lang='bash'> php artisan swagger-lume:publish-config (config/swagger-lume.php) php artisan swagger-lume:publish php artisan swagger-lume:generate </source> 四、指定swagger路由 <source lang='php'> //config/swagger-lume.php 'routes' => [ 'api' => 'api-docs', // from 'api/documentation' 'docs' => 'docs', ], </source> 五、设置自动更新文档 <source lang='php'> //config/swagger-lume.php 'generate_always' => env('SWAGGER_GENERATE_ALWAYS', true), </source> 如果不设置,要手动执行swagger-lume:generate命令,文档才能看到最新变化。 =Lumen= ==安装== ===安装composer=== 从 https://getcomposer.org/download/ 上下载安装文件。 ===利用Composer下载Lumen安装器=== <source lang="bash"> composer global require "laravel/lumen-installer=~1.0" # or composer global require "laravel/lumen-installer" </source> 安装时包名写错了,留下包痕迹清除不了,把composer卸载,重新安装后,才能用正确的包名安装lumen。 ===创建Lumen运用程序=== 通过lumen new命令就能在你指定的目录中创建一个干净的Lumen应用程序骨架了。 <source lang="bash"> lumen new app_name </source> ===部署到Web服务器=== Lumen 几乎不需要任何配置就能开箱即用。你能立即开始你的编码工作了! <source lang="text"> Lumen (5.2.8) (Laravel Components 5.2.*) </source> ==Creating custom helpers== Add the helpers.php file to your composer.json autoload files. <source lang="php"> "autoload": { "classmap": [ "database" ], "psr-4": { "Tasky\\": "app/" }, "files": [ "app/Support/helpers.php" ] }, </source> <source lang="text"> $ composer dumpautoload </source> =base64= =杂项= ==获取版本号== <source lang='php'> $app->get('/', function () use ($app) { return $app->version(); }); </source> ==指定302跳转== <source lang='php'> use Illuminate\Http\RedirectResponse; return redirect('/userInfo', 302); //默认为301 </source> =Lumen 5.2 中配置邮件= https://laravel-china.org/topics/1974 =技术文章收藏= [http://9iphp.com/web/php/php-datetime-package-carbon.html 日期及时间处理包 Carbon 在 Laravel 中的简单使用] [https://phphub.org/topics/2020 十个Laravel5程序优化技巧] [http://phphub.laravel-china.org/topics/2018 如何查看 Laravel 5 的所有数据库请求]
返回
Laravel
。
导航菜单
个人工具
登录
命名空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息