首页 > 后端开发 > php教程 > PHP框架学习之Laravel

PHP框架学习之Laravel

WBOY
发布: 2016-07-29 09:12:55
原创
786 人浏览过

自从接触PHP以来一直使用Yii,感觉Yii实现功能比较简单,是一个很不错的框架。最近由于工作的原因开始研究Laravel5,不得不说我在第一步安装就被坑着了,下面就是我痛苦的学习成果。Laravel对我来说完全是新东西,如果内容有误,烦请留言或QQ我,帮我纠正错误,感激不尽!!!

1.首先安装php,最好5.<span>6以上版本
  (</span>1)windows安装composer过程中需要指定php.<span>exe的路径
  (</span>2)linux安装composer过程中需要利用php-<span>cli功能

</span>2.<span>安装composer
  (</span>1<span>)windows安装composer
       a</span>.windows下载composer软件,<span>然后next直到完成
       b</span>.win+R => 输入cmd => 输入composer,<span> 如果出现composer字体表示安装成功
  (</span>2<span>)linux安装composer
       a</span>.$ curl -sS https:<span>//</span><span>getcomposer.org/installer | php</span>       b.此时在~/.composer下应该会产生composer.<span>phar 这个文件
       c</span>.$ mv  composer.phar  /usr/local/bin/<span>composer</span><span>       d</span>.将composer.phar移动成/usr/local/bin/composer全局下,以后可以直接使用composer,而不需要php  composer.<span>phar<br>       e.$ composer<br>3.修改composer镜像源(建议第一种)<br>   (1)将配置信息添加到 composer 的配置文件 <code>config.json</code> 中(系统全局配置)<br>    $</span><code>composer config -g repositories.packagist composer http://packagist.phpcomposer.com</code>
登录后复制
<span>   (2)</span>将配置信息添加到单个项目的 <code>composer.json</code> 文件中(单个项目配置)   <span>注意最后几行<code><span>repositories</span></code></span>
登录后复制
<code>{
     <span>name": <span><span>"laravel/laravel",
    "<span>description": <span><span>"The Laravel Framework.",
    "<span>keywords": <span>[<span>"framework", <span>"laravel"],
    "<span>license": <span><span>"MIT",
    "<span>type": <span><span>"project",
    "<span><strong>require</strong>": <span>{
        "<span>php": <span><span>">=5.5.9",
        "<span>laravel/framework": <span><span>"5.1.*"
    },
    "<span><strong>require</strong>-dev": <span>{
        "<span>fzaninotto/faker": <span><span>"~1.4",
        "<span>mockery/mockery": <span><span>"0.9.*",
        "<span>phpunit/phpunit": <span><span>"~4.0",
        "<span>phpspec/phpspec": <span><span>"~2.1"
    },
    "<span>autoload": <span>{
        "<span>classmap": <span>[
            <span>"database"
        ],
        "<span>psr-4": <span>{
            "<span>App\\": <span><span>"app/"
        }
    },
    "<span>autoload-dev": <span>{
        "<span>classmap": <span>[
            <span>"tests/TestCase.php"
        ]
    },
    "<span>scripts": <span>{
        "<span>post-install-cmd": <span>[
            <span>"php artisan clear-compiled",
            <span>"php artisan optimize"
        ],
        "<span>pre-update-cmd": <span>[
            <span>"php artisan clear-compiled"
        ],
        "<span>post-update-cmd": <span>[
            <span>"php artisan optimize"
        ],
        "<span>post-root-package-install": <span>[
            <span>"php -r \"copy('.env.example', '.env');\""
        ],
        "<span>post-create-project-cmd": <span>[
            <span>"php artisan key:generate"
        ]
    },
    "<span>config": <span>{
        "<span>preferred-install": <span><span>"dist"
    },
    "<span>repositories": <span>[
        {"<span>type": <span><span>"composer", "<span>url": <span><span>"http://packagist.phpcomposer.com"},
        {"<span>packagist": <span><span>false}
    ]
}</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code>
登录后复制
4.安装laravel<br>$ composer create-project laravel/laravel learnlaravel5<br>浏览器访问localhost/learnlaravel5/public,出现Laravel5表示laravel5安装成功
登录后复制

以上就介绍了PHP框架学习之Laravel,包括了require方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板