×ðÁú¿­Ê±¹ÙÍøµÇ¼

laravel ¿´²»¶®¿ò¼ÜÔ´Âë

laravel ÊÇÒ»¸öÊ¢ÐÐµÄ php ¿ò¼Ü £¬µ«¹ØÓÚÐí¶à³õѧÕßÀ´Ëµ £¬ÔĶÁ¿ò¼ÜÔ´ÂëÊÇÒ»¼þºÜÊÇÄÑÌâµÄÊÂÇé¡£±¾ÎĽ«ÊµÑéÚ¹ÊÍ laravel µÄ´úÂë½á¹¹ºÍÒªº¦²¿·Ö £¬×ÊÖú¶ÁÕ߸üºÃµØÃ÷È·Õâ¸ö¿ò¼Ü¡£

Laravel µÄ´úÂë½á¹¹

Laravel µÄ´úÂë½á¹¹ÊǺÜÊÇÇåÎúµÄ £¬Õû¸ö¿ò¼Ü±»ÆÊÎöΪ¶à¸ö×ÔÁ¦µÄÄ£¿é £¬Ã¿¸öÄ£¿éÓÐÆäÌض¨µÄÖ°ÔðºÍ¹¦Ð§¡£ÕâÖֽṹʹµÃ Laravel ¸üÈÝÒ×ά»¤ºÍ¿ª·¢¡£ÏÂÃæÊÇ Laravel Ö÷ҪĿ¼ºÍÎļþµÄÚ¹ÊÍ£º

app

¸ÃĿ¼°üÀ¨ÁË Laravel Ó¦ÓóÌÐòµÄ½¹µã´úÂë¡£Æä½¹µã¹¹½¨¿éÊÇ¿ØÖÆÆ÷¡¢ÊÓͼ¡¢Ä£×ӺͷÓÉ¡£

bootstrap

¸ÃĿ¼°üÀ¨ÁË Laravel Ó¦ÓóÌÐòÆô¶¯Ê±Ö´ÐеĴúÂë¡£ÈôÊÇÄãÏàʶ PHP ¿ò¼Ü £¬ÄÇôÕâ¸öĿ¼¶ÔÄãÀ´Ëµ²»»áÉúÊè £¬ºÃ±È×Ô¶¯¼ÓÔØÀà £¬¼ÓÔØÉèÖÃÎļþµÈ¡£

config

¸ÃĿ¼°üÀ¨ÁËÓ¦ÓóÌÐòµÄÉèÖÃÎļþ¡£

database

¸ÃĿ¼°üÀ¨ÁËÊý¾Ý¿âǨáãºÍÊý¾ÝÌî³äÎļþ¡£

public

¸ÃĿ¼°üÀ¨ÁËÓ¦ÓóÌÐòµÄ¹«¹²»á¼ûµã £¬Ó¦ÓóÌÐòµÄÈë¿ÚÊÇ index.php Îļþ¡£

resources

¸ÃĿ¼°üÀ¨ÁËһЩָ¶¨Ó¦ÓóÌÐòµÄ assets£¨ÈçÉèÖÃÎļþ¡¢ÊÓͼ¡¢ÓïÑÔÎļþ¡¢ JavaScript ÎļþºÍ CSS Îļþ£©¡£

routes

¸ÃĿ¼°üÀ¨ÁËÓ¦ÓóÌÐòµÄ·ÓÉÎļþ £¬¼´ url Óë¿ØÖÆÆ÷µÄÓ³Éä¡£

storage

¸ÃĿ¼°üÀ¨ÁËһЩ Laravel ÌìÉúµÄÎļþ £¬ÈçÈÕÖ¾Îļþ¡¢¿ò¼ÜÌìÉúµÄ»º´æ¡¢¿ò¼ÜÌìÉúµÄÎļþ £¬Èç·ÓÉ»º´æºÍ¿ò¼ÜÌìÉúµÄÊÓͼ¡£

tests

¸ÃĿ¼°üÀ¨Á˲âÊÔÓ¦ÓóÌÐòµÄ²âÊÔÎļþ¼Ð¡£

vendor

¸ÃĿ¼°üÀ¨ÁËÒÀÀµ°üµÄ´úÂë¡£Laravel ¿ò¼ÜÒÀÀµÓÚһЩ×Ô¼º¿ª·¢µÄ°üºÍÆäËû°ü¡£

Laravel µÄ²¿·ÖÒªº¦´úÂë

ÔÚ Laravel µÄ´úÂë½á¹¹ÖÐ £¬ÎÒÃÇÖصã¹Ø×¢µÄÊÇ app Îļþ¼ÐÖеĴúÂë¡£

¿ØÖÆÆ÷

¿ØÖÆÆ÷ÊÇ Laravel µÄÖ÷Òª²¿·Ö £¬ÓÃÓÚÏìÓ¦Ó¦ÓóÌÐòÖÐµÄ HTTP ÇëÇó¡£ÔÚ app/Http/Controllers Îļþ¼ÐÖн«»á¿´µ½ËùÓеĿØÖÆÆ÷Àà¡£ÏÂÃæÊÇÒ»¸öʾÀý¿ØÖÆÆ÷£º

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use AppUser;
use AppHttpControllersController;

class UserController extends Controller
{
    /**
     * ÏÔʾָ¶¨Óû§µÄСÎÒ˽ÈË×ÊÁÏ
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        return view('user.profile', ['user' => User::findOrFail($id)]);
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚ¿ØÖÆÆ÷ÖÐ £¬ÎÒÃÇ¿ÉÒÔ½ç˵²î±ðµÄÒªÁìÀ´½â¾ö²î±ðµÄÇéÐÎ £¬Èç $id ²ÎÊý¾Í¿ÉÒÔͨ¹ý show() ÒªÁìÀ´´¦Àí £¬¸ÃÒªÁ콫·µ»ØÊÓͼºÍÓû§µÄ ID¡£

Ä£×Ó

Ä£×ÓÊÇ Laravel Öд¦ÀíÊý¾Ý¿âµÄÒ»ÖÖÒªÁì £¬ÊÇÓëÊý¾Ý¿â±íÏà¹ØÁªµÄ PHP Àà¡£ÔÚ app Îļþ¼ÐÖÐ £¬app/Models Îļþ¼ÐÖдæ·Å×ÅÖÖÖÖÄ£×Ó £¬ÈçÏÂÃæµÄʾÀý User Ä£×Ó£º

<?php

namespace AppModels;

use IlluminateDatabaseEloquentModel;

class User extends Model
{
    /**
     * Ä£×ÓµÄĬÈÏÊôÐÔÖµ¡£
     *
     * @var array
     */
    protected $attributes = [
        'can_send_email' => false,
    ];
}

µÇ¼ºó¸´ÖÆ

ÔÚÄ£×ÓÖÐ £¬ÎÒÃÇ¿ÉÒÔ½ç˵²î±ðµÄÊôÐÔºÍÒªÁìÀ´ÊµÏÖ¶ÔÊý¾Ý¿â±íµÄ²Ù×÷ £¬ºÃ±È $attributes ÊôÐÔ¿ÉÒÔÉèÖÃÄ£×ÓµÄĬÈÏÊôÐÔÖµ £¬¿ÉÒÔÏñÏÂÃæÕâÑù»ñÈ¡Ò»¸ö User Ä£×Ó£º

$user = AppModelsUser::find($id);

µÇ¼ºó¸´ÖÆ

ÊÓͼ

ÊÓͼÊÇÓÃÓÚÏòÓû§¿É¶ÁµÄ·½·¨·ºÆðÊý¾ÝºÍÐÅÏ¢µÄÒ»ÖÖÒªÁì¡£ÔÚ resources/views Îļþ¼ÐÏ¿ÉÒÔ¿´µ½ËùÓеÄÊÓͼÎļþ¡£ÊÓͼͨ³£°üÀ¨ HTML¡¢CSS ºÍ JavaScript ´úÂë¡£

ÏÂÃæÊÇÒ»¸ö¼òÆ Blade Ä£°åʾÀý£º

<!doctype html>
<html>
    <head>
        <title>Laravel</title>
    </head>
    <body>
        <div class="container">
            @yield('content')
        </div>
    </body>
</html>

µÇ¼ºó¸´ÖÆ

ÔÚ¸ÃʾÀýÄ£°åÖÐ £¬ÎÒÃÇ¿ÉÒÔ½ç˵ÎÊÌâºÍÒ»¸öÈÝÆ÷À´Ç¶Ì×Ò³ÃæÄÚÈÝ £¬²¢Í¨¹ý @yield(‘content’) À´²åÈëÄÚÈÝ¡£

·ÓÉ

·ÓÉÓÃÓÚ½« URL ºÍÓ¦ÓóÌÐòÖеĴúÂëÏàÆ¥Åä £¬¶ÔÓ¦ Laravel ÖеÄ·ÓÉÎļþ¿ÉÒÔÔÚ routes/web.php ÖÐÕÒµ½¡£ÏÂÃæÊÇÒ»¸öʾÀý·ÓÉ£º

<?php

use IlluminateSupportFacadesRoute;
use AppHttpControllersUserController;

Route::get('/user/{id}', [UserController::class, 'show']);

µÇ¼ºó¸´ÖÆ

ÔÚ¸ÃʾÀý·ÓÉÖÐ £¬ÎÒÃÇΪÓû§ÇëÇó½¨ÉèÁËÒ»¸ö URL ģʽ £¬½«ÔÚ UserController::show() ÒªÁìÖд¦ÀíËùÓеÄÇëÇó¡£

×ܽá

Laravel µÄ´úÂë½á¹¹ºÍ½¹µã²¿·ÖÖ÷Òª¼¯ÖÐÔÚ app Îļþ¼ÐÖС£¿ØÖÆÆ÷¡¢Ä£×Ó¡¢ÊÓͼºÍ·ÓÉÊÇ Laravel ÖкÜÊÇÖ÷ÒªµÄËIJ¿·Ö¡£Ö»ÒªÑ§»áÁËÕâЩ²¿·ÖÔÚ´úÂëÖеÄʵÏÖ·½·¨ £¬¾Í¿ÉÒÔ¸üºÃµØÃ÷È· Laravel µÄÔË×÷¡£ËäÈ» £¬Laravel µÄ¿ª·¢ÕßÒ²ÔÚÒ»Ö±µØ¸øÕâЩ²¿·ÖÌí¼ÓÐµĹ¦Ð§ £¬ÒÔÊÇѧϰ Laravel µÄÀú³ÌÒ²ÊÇÒ»Á¬Ò»Ö±µÄ¡£

ÒÔÉϾÍÊÇlaravel ¿´²»¶®¿ò¼ÜÔ´ÂëµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ