Hello Laravel

本地安装homestead

vagrant box add laravel/homestead ./virtualbox.box

Lumen

  1. cp .env.example .env
  2. 修改 lumen/bootstrap/app.php 文件,将 Dotenv::load 的注释移除掉。
  3. D:\xampp\apache\conf\extra\httpd-vhosts.conf

    NameVirtualHost *:80
    
    <VirtualHost *:80>
        ##ServerAdmin webmaster@dummy-host.example.com
        DocumentRoot "D:/work_php/service/public/"
        ServerName www.a.com
        <Directory "D:/work_php/service/public/">
            Require all granted
        </Directory>
    </VirtualHost>
    
  4. chrome://net-internals/#dnschrome://net-internals/#sockets#Google Chrome virtual hosts not working with ERR_NAME_NOT_RESOLVED error after update http://www.cnblogs.com/hustskyking/p/hosts-modify.html

mysql修改root密码

  1. update user set password=password('123456') where User='root'
  2. 修改phpmyadmin下的config.inc.php

    $cfg['Servers'][$i]['auth_type'] = 'config';
    $cfg['Servers'][$i]['user'] = 'root';
    $cfg['Servers'][$i]['password'] = '123456';
    $cfg['Servers'][$i]['extension'] = 'mysqli';
    $cfg['Servers'][$i]['AllowNoPassword'] = false;
    
  3. 如果不行,接着再进入phpmyadmin下的libraries目录,修改config.default.php文件。找到$cfg['Servers'][$i]['password'] = ' '
    修改为$cfg['Servers'][$i]['password'] = '123456';
    123456就是您想要的密码。重启mysql后新密码生效。

How to enable rewrite module in XAMPP

  1. 打开{xampp_dir}/apache/conf/httpd.conf
  2. 去掉#LoadModule rewrite_module modules/mod_rewrite.so前面的井号
  3. Now search for another string AllowOverride None and replace it by AllowOverride All
    Finally save the changes, close your text editor and restart your apache server.

laravel

  1. 安装,推荐通过 Laravel 安装工具安装 Laravel

    1. composer global require "laravel/installer"
    2. 请确保 PATH 环境变量已经添加了 ~/.composer/vendor/bin 目录
    3. laravel new yourapp 或者composer create-project laravel/laravel yourapp
  2. quickstart 中文

    git clone https://github.com/laravel/quickstart-basic quickstart
    cd quickstart
    composer install
    php artisan migrate
    
  3. 创建完成之后进入到blog目录,修改app/config/app.php中的timezone为PRC、locale为zh

  4. composer dump-autoload#FatalErrorException报这个错就执行
  5. Demo auth auth2

    // Authentication routes...
    Route::get('auth/login', 'Auth\AuthController@getLogin');
    Route::post('auth/login', 'Auth\AuthController@postLogin');
    Route::get('auth/logout', 'Auth\AuthController@getLogout');
    
    // Registration routes...
    Route::get('auth/register', 'Auth\AuthController@getRegister');
    Route::post('auth/register', 'Auth\AuthController@postRegister');
    
    
    Route::controllers([
        'password' => 'Auth\PasswordController',
    ]);
    
  6. 重置密码
  7. demo

    • php artisan make:migration create_mydatas_table --create=mydatas#创建一个“数据库迁移(migration)”,其对应一张数据库表mydatas

      #迁移文件会被放在项目下的 database/migrations 文件夹中
      <?php
      
      use Illuminate\Database\Schema\Blueprint;
      use Illuminate\Database\Migrations\Migration;
      
      class CreateMydatasTable extends Migration
      {
          /**
           * Run the migrations.
           *
           * @return void
           */
          public function up()
          {
              Schema::create('mydatas', function (Blueprint $table) {
                  $table->increments('id');
                  $table->string('name');#你手动添加的一个字段
                  $table->timestamps();
              });
          }
      
          /**
           * Reverse the migrations.
           *
           * @return void
           */
          public function down()
          {
              Schema::drop('mydatas');
          }
      }
      
    • php artisan migrate#执行数据迁移,会在数据库中add mydatas这张表
    • php artisan make:model MyData
    • php artisan make:model --migration MyDataphp artisan make:model -m MyData#上面make:migration和make:model可以用这一句代替
    • php artisan make:migration add_content_to_tasks_table --table=tasks#增加一列
    • php artisan make:controller TaskController

      #\app\Http\routes.php
      /**
       * Show Task Dashboard
       */
      Route::get('/','TaskController@index');
      
      /**
       * Show Task Dashboard
       */
      Route::get('/task/{id}', 'TaskController@show');
      
      
      /**
       * Add New Task
       */
      Route::post('/task', 'TaskController@store');
      
      /**
       * Delete Task
       */
      Route::delete('/task/{id}', 'TaskController@destroy');
      
      
      #\app\Http\Controllers\TaskController.php
      <?php
      
      namespace App\Http\Controllers;
      
      use Illuminate\Http\Request;
      use App\Http\Requests;
      use App\Task;
      use Validator;
      
      class TaskController extends Controller
      {
          /**
           * Display a listing of the resource.
           *
           * @return \Illuminate\Http\Response
           */
          public function index()
          {
              return view('tasks', [
                  'tasks' => Task::orderBy('created_at', 'asc')->get()
              ]);
          }
      
          /**
           * Show the form for creating a new resource.
           *
           * @return \Illuminate\Http\Response
           */
          public function create()
          {
              //
          }
      
          /**
           * Store a newly created resource in storage.
           *
           * @param  \Illuminate\Http\Request  $request
           * @return \Illuminate\Http\Response
           */
          public function store(Request $request)
          {
              $validator = Validator::make($request->all(), [
                  'name' => 'required|max:255',
              ]);
      
              if ($validator->fails()) {
                  return redirect('/')
                      ->withInput()
                      ->withErrors($validator);
              }
      
              $task = new Task;
              $task->name = $request->name;
              $task->save();
      
              return redirect('/');
          }
      
          /**
           * Display the specified resource.
           *
           * @param  int  $id
           * @return \Illuminate\Http\Response
           */
          public function show($id)
          {
              $task = Task::findOrNew($id);
              print $task;
          }
      
          /**
           * Show the form for editing the specified resource.
           *
           * @param  int  $id
           * @return \Illuminate\Http\Response
           */
          public function edit($id)
          {
              //
          }
      
          /**
           * Update the specified resource in storage.
           *
           * @param  \Illuminate\Http\Request  $request
           * @param  int  $id
           * @return \Illuminate\Http\Response
           */
          public function update(Request $request, $id)
          {
              //
          }
      
          /**
           * Remove the specified resource from storage.
           *
           * @param  int  $id
           * @return \Illuminate\Http\Response
           */
          public function destroy($id)
          {
              Task::findOrFail($id)->delete();
      
              return redirect('/');
          }
      }
      
  8. laravelcollective/html

    参考

    "require": {
        "laravelcollective/html": "5.1.*"
    }
    

    composer update

    config/app.php:

    'providers' => [
        // ...
        Collective\Html\HtmlServiceProvider::class,
        // ...
    ]
    
    
    'aliases' => [
        // ...
        'Form' => Collective\Html\FormFacade::class,
        'Html' => Collective\Html\HtmlFacade::class,
        // ...
    ],      
    
  9. 发布到阿里云ECS(我用的oninstack)

    1. 配置vhost,必须有如下字段:

      server {
      server_name task.xxxx.com;
      index index.php index.html index.htm;
      root /data/wwwroot/task.xxxx.com/public;
      location / {
          try_files $uri $uri/ /index.php?$query_string;
          }
      }
      
    2. 解析你相应的网址task.xxxx.com,这个时候,主页面应该可以访问了。

    3. 配置数据库
    4. 权限
      chown -R www:www task.xxxx.com
      chmod -R 775 ./task.xxxx.com/quickstart-intermediate/storage
  10. artisanartisan

    1. 自学成才

      php artisan list
      php artisan help migrate
      
  11. 下载文件报错

    uncomment this line in php.ini into php folder. extension=php_fileinfo.dll

  12. 其它

    理解OAuth 2.0

发布了90 篇原创文章 · 获赞 8 · 访问量 16万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览