zoukankan      html  css  js  c++  java
  • 初学laravel

    配合postman 工具初学laravel

    中文文档

     http://laravelacademy.org/post/2784.html

    一、路由部分

    laravel初始化的时候

    先屏蔽这一行,然后进行路由测试

    在routes.php里面写这些东西,然后一个一个测试

    Route::get('/', function () {
       return view('welcome');
    });
    Route::get('user/{id}', function ($id) {
        return 'User '.$id;
    });
    Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
        return $postId.'--'.$commentId;
    });
    Route::get('user_{name}', function ($name) {
        return $name;
    });
    Route::get('aa/{name}', function ($name) {
        return $name;
    })->where('name', '[A-Za-z]+');
    Route::get('user/{id}/{name}', function ($id, $name) {
        return $id.'--'.$name;
    })->where(['id' => '[0-9]+', 'name' => '[a-z]+']);
    //Route::get('/foo', function () {
    //    echo  "get";
    //});
    //Route::post('/foo', function () {
    //    echo  "post";
    //});
    //Route::put('/foo', function () {
    //    echo  "put";
    //});

     在post上面挨个调试即可

    二、控制器部分

    http://laravelacademy.org/post/2816.html

    在http/controllers下面新建一个控制器IndexController.php

    <?php
    
    namespace AppHttpControllers;
    
    class IndexController extends Controller
    {
        public function index(){
            echo "123";
        }
    }

    路由里面

    <?php
    
    /*
    |--------------------------------------------------------------------------
    | Application Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register all of the routes for an application.
    | It's a breeze. Simply tell Laravel the URIs it should respond to
    | and give it the controller to call when that URI is requested.
    |
    */
    
    Route::get('/', function () {
       return view('welcome');
    });
    
    Route::get('test', 'IndexController@index');

    访问http://www.blog.com/test

    artisan创建控制器

    php artisan make:controller UserController

     

     

     新建立控制器 分层

  • 相关阅读:
    EL表达式与JSTL
    jsp
    Servlet 会话
    Servlet 常用类
    Servlet
    Java 网络编程
    CentOS系统下安装python3+Django
    转载Alpine Linux常用命令
    转载Alpine基础
    CentOS启动docker1.13失败(Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.)
  • 原文地址:https://www.cnblogs.com/php0916/p/7774831.html
Copyright © 2011-2022 走看看