ホームページ >バックエンド開発 >PHPチュートリアル >Laravelを学ぶPHPフレームワーク

Laravelを学ぶPHPフレームワーク

WBOY
WBOYオリジナル
2016-07-29 09:12:55790ブラウズ

自从接触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教程有兴趣的朋友有所帮助。

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。