PHP Laravel 快速入门

PHP 框架 Laravel 搭建开始, 慢慢更新~ 😜😜😜😜

Quit Start

一. 安装composer, 用于管理依赖

1
2
3
4
5
6
# 全局安装 macOS
brew update
brew tap josegonzalez/homebrew-php
brew tap homebrew/versions
brew install php55-intl
brew install josegonzalez/php/composer

二. 下载laravel

1
composer global require "laravel/installer"

三. 创建项目

1
composer create-project laravel/laravel --prefer-dist

四. 关于如何使用PhpStorm

默认已经配置好PHP开发环境了!

4.0.1 相关插件

  • Laravel Plugin
  • [Optional] PHP Annotations Plugin
  • [Optional] Symfony2 Plugin

4.1 配置Composer

  • 右键项目根节点 -> Composer -> init composer, 配置PHP解释器Composer路径

image

  • 右键项目根节点 -> Composer -> add dependency, 添加barryvdh/laravel-ide-helper

image
或者

1
composer require barryvdh/laravel-ide-helper

4.2 编辑config/app.php文件, 在providers节点下面添加
image

4.3 扩展命令工具

  • Preferences -> Tools -> Command Line Tool Support

image

image

使用: Tools -> Run Command(⌘ + ⇧ + X)

image

4.4 配置 php-xdebug

1
2
# 检查是否安装php-xdebug
php -m

安装后,修改下php.ini把xdebug.so前的注释’;’去掉

image

五. 配置启动
image

六. 配置Debug

image
并且在根目录加入debug.ini

1
2
3
4
5
6
7
8
9
10
11
12
xdebug.remote_enable = On
xdebug.remote_autostart = On
upload_max_filesize = 1000M
post_max_size = 1005M
max_execution_time = 120

;xdebug.profiler_enable = On
;xdebug.profiler_enable_trigger = Off
;xdebug.profiler_output_dir = ./xdebug
;xdebug.profiler_aggregate = On
;xdebug.profiler_append = On
;xdebug.profiler_output_name = "cachegrind.out.%R.%u.%p"

资源

Laravel Live Templates for PhpStorm
Laravel 插件视频

标签

  • 继承
    @extends

  • 存在替换
    @yield('content')
    @section
    @endsection

  • 增加
    @stack("appendCSS")
    @push('appendCSS')
    @endpush

  • 注入
    @inject("xx", "xx[Name]")

分享到