尊龙凯时人生就是搏

laravelн¨Ä£¿éÁ÷³Ì

laravelÊÇÒ»¿îÏÖ´ú»¯µÄphp¿ò¼Ü £¬ÌṩÁ˸»ºñµÄ¹¦Ð§ºÍ¹¤¾ß £¬Ê¹µÃ¿ª·¢Õß¿ÉÒÔ¸ßЧµØ¿ª·¢webÓ¦ÓóÌÐò¡£ÆäÖÐ £¬Ä£¿é»¯±à³ÌÊÇÒ»ÖÖ¼«ÎªÖ÷ÒªµÄ±à³ÌÍ·ÄÔ £¬ÔÚlaravelÖÐÒ²ÓÐןܺõÄÌåÏÖ¡£±¾ÆªÎÄÕ½«ÏÈÈÝÔÚlaravelÖÐн¨Ä£¿éµÄÁ÷³ÌºÍ°ì·¨¡£

Ò»¡¢½¨ÉèÄ£¿éĿ¼½á¹¹

ÔÚLaravelÖÐ £¬Ä£¿éÊÇÓÉһЩÏà¹ØµÄ¿ØÖÆÆ÷¡¢Ä£×Ó¡¢ÊÓͼ¡¢ÓïÑÔ°üµÈ×é³ÉµÄÜöÝÍ £¬Òò´Ë £¬ÔÚн¨Ä£¿éÇ° £¬ÐèÒªÏȽ¨ÉèÄ£¿éµÄĿ¼½á¹¹¡£ÔÚLaravelµÄ¸ùĿ¼Ï £¬½¨ÉèÃûΪ”Modules”µÄĿ¼ £¬²¢ÔÚÕâ¸öĿ¼Ï½¨Éè”Example”Ä£¿éµÄĿ¼ £¬½á¹¹ÈçÏ£º

app/Modules/Example
©À©¤©¤ Config
©¦   ©¸©¤©¤ config.php
©À©¤©¤ Controllers
©¦   ©¸©¤©¤ ExampleController.php
©À©¤©¤ Models
©¦   ©À©¤©¤ Example.php
©¦   ©¸©¤©¤ ExampleRepository.php
©À©¤©¤ Resources
©¦   ©À©¤©¤ Lang
©¦   ©¦   ©À©¤©¤ en
©¦   ©¦   ©¦   ©¸©¤©¤ example.php
©¦   ©¦   ©¸©¤©¤ zh
©¦   ©¦       ©¸©¤©¤ example.php
©¦   ©À©¤©¤ Views
©¦   ©¦   ©¸©¤©¤ index.blade.php
©¦   ©¸©¤©¤ assets
©À©¤©¤ Routes
©¦   ©À©¤©¤ api.php
©¦   ©¸©¤©¤ web.php
©¸©¤©¤ Providers
    ©¸©¤©¤ ExampleServiceProvider.php

µÇ¼ºó¸´ÖÆ

ÉÏÊöĿ¼½á¹¹ÖÐ £¬ConfigÄ¿ÈÎÃüÀ´´æ·ÅÄ£¿éµÄÉèÖÃÎļþ £¬ControllersĿ¼´æ·Å¿ØÖÆÆ÷Îļþ £¬ModelsĿ¼´æ·ÅÄ£×ÓÎļþ £¬ResourcesĿ¼´æ·ÅÆäËû×ÊÔ´Îļþ £¬ÈçÊÓͼ¡¢ÓïÑÔ°ü¡¢¾²Ì¬ÎļþµÈ £¬RoutesÄ¿ÈÎÃüÀ´´æ·Å¸ÃÄ£¿éµÄ·ÓÉÎļþ £¬ProvidersÄ¿ÈÎÃüÀ´´æ·Å¸ÃÄ£¿éµÄЧÀÍÌṩÕß¡£ÆäÖÐ £¬ExampleΪ¸ÃÄ£¿éµÄÃû³Æ £¬¿ÉÒÔƾ֤ÏÖʵÐèÇóÃüÃû¡£

¶þ¡¢ÉèÖ÷ÓÉÎļþ

ÔÚLaravelÖÐ £¬Â·ÓÉÊǽ«URIÓ³Éäµ½Ìض¨µÄ²Ù×÷µÄµØ·½¡£Òò´Ë £¬ÔÚн¨Ä£¿éʱ £¬ÐèÒªÉèÖøÃÄ£¿éµÄ·ÓÉÎļþ¡£ÔÚExampleÄ£¿éµÄRoutesĿ¼Ï £¬Ð½¨web.phpºÍapi.phpÁ½¸öÎļþ £¬²¢ÔÚÕâÁ½¸öÎļþÖл®·Ö½ç˵¸ÃÄ£¿éµÄǰ̨ºÍºǫ́·ÓÉ¡£

ÏÂÃæÊÇÒ»¸öʾÀý£º

//web.php
Route::group(['module' => 'Example', 'middleware' => ['web']], function() {
    Route::get('/', 'ExampleController@index');
});

//api.php
Route::group(['module' => 'Example', 'namespace' => 'AppModulesExampleControllersApi', 'prefix' => 'api/v1', 'middleware' => ['api']], function() {
    Route::get('/', 'ExampleApiController@index');
});

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀýÖÐ £¬web.phpÎļþ½ç˵ÁËÒ»¸ögetÇëÇó £¬½«¸ùĿ¼”/”Ó³Éäµ½Example¿ØÖÆÆ÷µÄindexÒªÁìÉÏ¡£¶øapi.phpÎļþ½ç˵ÁËÒ»¸ögetÇëÇó £¬½«”/api/v1″Ó³Éäµ½ExampleApiController¿ØÖÆÆ÷µÄindexÒªÁìÉÏ¡£ÆäÖÐ £¬’module’²ÎÊýÖ¸¶¨Á˸÷ÓÉÊôÓÚExampleÄ£¿é £¬’middleware’²ÎÊýÖ¸¶¨Á˸÷ÓÉÒÀÀµÓÚwebÖÐÐļþ»òapiÖÐÐļþ £¬ÕâЩÖÐÐļþ¿ÉÒÔƾ֤ÏêϸÇéÐξÙÐÐÉèÖá£

Èý¡¢½¨Éè¿ØÖÆÆ÷

¿ØÖÆÆ÷ÊÇLaravelÖÐÓÃÓÚ´¦ÀíÓû§ÇëÇóµÄÒ»ÖÖ»úÖÆ¡£ÔÚExampleÄ£¿éµÄControllersĿ¼Ï £¬Ð½¨ExampleController.phpÎļþ £¬²¢½ç˵һ¸öindexÒªÁì×÷ΪʾÀý¡£

ʾÀý´úÂëÈçÏ£º

namespace AppModulesExampleControllers;

use AppHttpControllersController;

class ExampleController extends Controller {

    public function index() {
        return view('example::index');
    }

}

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀýÖÐ £¬ExampleControllerÀà¼ÌÐø×ÔLaravel¿ò¼ÜÌṩµÄControllerÀà £¬Ëü°üÀ¨Ò»¸öindexÒªÁì £¬¸ÃÒªÁ콫ģ°åÎļþexample::index·µ»Ø¡£

ËÄ¡¢½¨ÉèÊÓͼÎļþ

ÔÚLaravelÖÐ £¬ÊÓͼÓÃÓÚÏÔʾHTMLÒ³Ãæ»òÆäËûÏìÓ¦Êý¾Ý¡£ÔÚExampleÄ£¿éµÄResourcesĿ¼Ï £¬Ð½¨ViewsĿ¼ £¬²¢ÔÚÆäÖн¨Éèindex.blade.php £¬¸ÃÎļþÊÇÓÃÀ´×÷ΪÀý×ÓµÄÊÓͼÎļþ¡£

ʾÀý´úÂëÈçÏ£º

<!DOCTYPE html>
<html>
<head>
    <title>Example</title>
</head>
<body>
    <h1>Welcome to Example Module!</h1>
</body>
</html>

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀýÖÐ £¬index.blade.phpÎļþÖ»°üÀ¨Ò»¸ö¼òÆӵĽӴýÓï¾ä £¬ÓÃÀ´ÌåÏÖÕâÊǸÃÄ£¿éµÄÊ×Ò³¡£

Îå¡¢½¨ÉèÄ£×ÓºÍЧÀÍÌṩÕß

ÔÚLaravelÖÐ £¬Ä£×ÓÓÃÓÚÓëÊý¾Ý¿â½»»¥ £¬Í¨³£ÓÃÀ´·â×°Ò»Õűí¡£ÔÚExampleÄ£¿éµÄModelsĿ¼Ï £¬½¨ÉèExample.phpºÍExampleRepository.phpÁ½¸öÎļþ £¬»®·Ö´ú±íÄ£×ӺͲִ¢Àà £¬ËüÃǵÄ×÷Óû®·ÖÊÇÓëÊý¾Ý¿â½»»¥ºÍ·âװһЩÅÌÎÊÒªÁì¡£

ÔÚ½¨ÉèÍê³ÉÄ£×ӺͲִ¢ÀàÖ®ºó £¬ÐèÒªÔÚProvidersĿ¼Ï½¨ÉèÒ»¸öЧÀÍÌṩÕß £¬ÓÃÓÚ×¢²áÄ£×ӺͲִ¢Àà £¬Í¬Ê±ÊµÏÖЧÀÍÌṩÕßµÄregisterÒªÁì¡£

ʾÀý´úÂëÈçÏ£º

namespace AppModulesExampleProviders;

use IlluminateSupportServiceProvider;

class ExampleServiceProvider extends ServiceProvider {

    public function boot() {
        
    }

    public function register() {
        $this->app->bind('AppModulesExampleModelsExampleRepositoryInterface', 'AppModulesExampleModelsExampleRepository');
    }

}

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʾÀýÖÐ £¬ExampleServiceProviderÀà¼ÌÐø×ÔLaravel¿ò¼ÜÌṩµÄServiceProviderÀà £¬Í¨¹ýregisterÒªÁì×¢²áÁËExampleRepository½Ó¿ÚºÍExampleRepositoryʵÏÖÀà¡£ÔÚÏÖʵʹÓÃʱ £¬¿ÉÒÔͨ¹ýÈÝÆ÷»ñÈ¡ExampleRepositoryʵÀý £¬È»ºóŲÓÃÆäÒªÁìÀ´ÊµÏÖÓëÊý¾Ý¿â½»»¥µÄ¹¦Ð§¡£

×ܽ᣺

Ä£¿é»¯±à³ÌÊÇÒ»ÖÖºÜÊÇÖ÷ÒªµÄ±à³ÌÍ·ÄÔ £¬ÔÚLaravelÖÐÒ²ÓÐ×ÅÓÅÒìµÄÌåÏÖ¡£Í¨¹ýÉÏÊöµÄ°ì·¨ £¬ÎÒÃÇ¿ÉÒÔÔÚLaravelÖÐÇáËɵؽ¨ÉèÒ»¸öÄ£¿é £¬²¢ÊµÏÖÓëÊý¾Ý¿âµÄ½»»¥ºÍÏêϸµÄÓªÒµÂß¼­¡£ËäÈ» £¬ÔÚÏÖʵÏîÄ¿ÖÐ £¬Ä£¿éµÄÉè¼ÆÓëʵÏÖ²»Ö¹ÓÚ´Ë £¬ÐèҪ͎áÏêϸӪҵÐèÇó¾ÙÐкÏÀíÉè¼ÆºÍ¿ª·¢¡£

ÒÔÉϾÍÊÇlaravelн¨Ä£¿éÁ÷³ÌµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ