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

Laravel¿ª·¢£ºÔõÑùʹÓÃLaravel Artisan¾ÙÐÐÏÂÁîÐнçÃ濪·¢£¿

laravelÊÇÒ»¿îºÜÊÇÊ¢ÐеÄphp¿ò¼Ü£¬Ëü½ÓÄÉÁËÏÖ´ú»¯µÄ¼Ü¹¹ºÍÉè¼Æģʽ£¬ÔÚ¿ª·¢webÓ¦Ó÷½ÃæÓкܴóµÄÓÅÊÆ¡£ÆäÖУ¬laravel artisanÊÇlaravelÖеÄÒ»¸öºÜÊÇÖ÷ÒªµÄÏÂÁîÐй¤¾ß£¬Ëü¿ÉÒÔ×ÊÖúÎÒÃÇ¿ìËÙ½¨ÉèºÍά»¤Ó¦ÓóÌÐò¡£

ÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«ÏÈÈÝÔõÑùʹÓÃLaravel Artisan¾ÙÐÐÏÂÁîÐнçÃ濪·¢¡£ÎÒÃǽ«´ÓÔõÑùʹÓÃArtisanÌìÉú´úÂë¹Ç¼Ü×îÏÈ£¬È»ºó½â˵ÔõÑù±àд×Ô¼ºµÄÏÂÁî¡£×îºó£¬ÎÒÃǽ«ÏÈÈÝÔõÑùÔÚLaravelÓ¦ÓóÌÐòÖÐʹÓÃ×Ô¼ºµÄÏÂÁî¡£

Ò»¡¢ÌìÉú´úÂë¹Ç¼Ü

ʹÓÃLaravel ArtisanÌìÉú´úÂë¹Ç¼ÜÊÇÒ»¸öºÜÊÇÓÐÓõķ½·¨£¬¿ÉÒÔ¿ìËÙ½¨Éè¿ØÖÆÆ÷¡¢Ä£×Ó¡¢Ç¨áãµÈÎļþ¡£ÀýÈ磬ÈôÊÇÎÒÃÇÏëÒª½¨ÉèÒ»¸öÃûΪUserµÄÄ£×ÓºÍÏìÓ¦µÄÊý¾Ý¿âǨáãÎļþ£¬ÎÒÃÇ¿ÉÒÔÔÚÏÂÁîÐд°¿ÚÖÐÔËÐÐÒÔÏÂÏÂÁ

php artisan make:model User -m

µÇ¼ºó¸´ÖÆ

Õ⽫ÌìÉúÒ»¸öUser.phpÄ£×ÓÎļþºÍÒ»¸ö2019_01_01_000000_create_users_table.phpǨáãÎļþ¡£×¢ÖØ£¬ÎÒÃÇÔÚÏÂÁîºóÃæ¼ÓÉÏÁË¡°-m¡±±ê¼Ç£¬ÕâÒâζ×ÅÎÒÃÇ»¹Òª½¨ÉèÒ»¸öÊý¾Ý¿âǨáãÎļþ¡£

ͬÑù£¬ÎÒÃÇÒ²¿ÉÒÔʹÓÃArtisanÀ´½¨Éè¿ØÖÆÆ÷£º

php artisan make:controller UserController

µÇ¼ºó¸´ÖÆ

Õ⽫ÌìÉúÒ»¸öUserController.phpÎļþ¡£

³ýÁËÄ£×ӺͿØÖÆÆ÷£¬Laravel Artisan»¹¿ÉÒÔ×ÊÖúÎÒÃÇÌìÉúÐí¶àÆäËûÀàÐ͵ĴúÂëÎļþ£¬°üÀ¨Óʼþ¡¢ÊÂÎñ¡¢¼àÌýÆ÷µÈµÈ¡£Ê¹ÓÃArtisanÌìÉú´úÂë¹Ç¼ÜºÜÊÇÀû±ã£¬¿ÉÒÔ´ó´óïÔÌ­ÎÒÃǵÄÊÂÇéÁ¿¡£

¶þ¡¢±àд×Ô½ç˵ÏÂÁî

³ýÁËÌìÉú´úÂë¹Ç¼Ü£¬Laravel Artisan»¹¿ÉÒÔ×ÊÖúÎÒÃDZàд×Ô¼ºµÄÏÂÁî¡£¿ÉÒÔʹÓÃArtisanÏÂÁîÐй¤¾ß¶ø²»ÊǹŰåµÄ¿ØÖÆÆ÷·ÓÉÀ´Ö´ÐÐÕâЩÏÂÁî¡£

Òª½¨ÉèÒ»¸ö×Ô½ç˵ÏÂÁÎÒÃÇÊ×ÏÈÐèÒªÔÚÏÂÁîÐÐÖÐʹÓÃArtisanÌìÉúÒ»¸öÏÂÁî¹Ç¼Ü£¬ÈçÏÂËùʾ£º

php artisan make:command SendMail

µÇ¼ºó¸´ÖÆ

ÉÏÊöÏÂÁ½¨ÉèÒ»¸öÃûΪSendMailµÄÏÂÁîÄ£°å¡£´ËÄ£°å½«°üÀ¨Ò»¸öĬÈÏÃû³ÆΪ¡°handle¡±µÄÒªÁ죬ÎÒÃÇ¿ÉÒÔÔÚ´ËÒªÁìÖбàдÎÒÃǵÄÏÂÁîÂß¼­¡£

ÔÚÕâÀÎÒÃǽ«ÊµÏÖÒ»¸ö¼òÆÓµÄSendMailÏÂÁËü»áÏòÖ¸¶¨µÄÓÊÏä·¢ËÍÒ»·â²âÊÔÓʼþ¡£ÔÚн¨ÉèµÄSendMail.phpÎļþÖУ¬ÊäÈëÒÔÏ´úÂ룺

<?php

namespace AppConsoleCommands;

use IlluminateConsoleCommand;
use IlluminateSupportFacadesMail;

class SendMail extends Command
{
    protected $signature = 'sendmail {email}';

    protected $description = 'Send a test email to the given address.';

    public function handle()
    {
        $email = $this->argument('email');
        Mail::raw('This is a test email!', function ($message) use ($email) {
            $message->to($email)->subject('Test Email');
        });
        $this->info('The test email was sent successfully!');
    }
}

µÇ¼ºó¸´ÖÆ

ÉÏÊö´úÂëÊ×ÏȽç˵ÁËÒ»¸öÃûΪ¡°sendmail¡±µÄÏÂÁËü°üÀ¨Ò»¸öemail²ÎÊý£¬¸Ã²ÎÊýÖ¸¶¨ÁËÒªÏòÄĸöµç×ÓÓʼþµØµã·¢ËͲâÊÔÓʼþ¡£ÎÒÃǽç˵ÁËÒ»¸ö¡°handle¡±ÒªÁ죬Ëü´Ó²ÎÊýÖжÁÈ¡µç×ÓÓʼþµØµã£¬È»ºóʹÓÃLaravelµÄÓʼþ¹¦Ð§·¢ËͲâÊÔÓʼþ¡£×îºó£¬ÎÒÃÇŲÓÃ$this->info()ÒªÁ죬Êä³öÀÖ³ÉÐÅÏ¢¡£

Èý¡¢ÔÚLaravelÓ¦ÓóÌÐòÖÐʹÓÃ×Ô½ç˵ÏÂÁî

ÏÖÔÚÎÒÃÇÒѾ­±àдÁË×Ô½ç˵ÏÂÁ½ÓÏÂÀ´ÎÒÃǽ«¿´¿´ÔõÑùÔÚLaravelÓ¦ÓóÌÐòÖÐʹÓÃËü¡£

ÒªÔÚÓ¦ÓóÌÐòÖÐʹÓÃ×Ô½ç˵ÏÂÁÎÒÃÇÐèÒª½«ËüÃÇ×¢²áµ½ArtisanÏÂÁîÐй¤¾ßÖС£ÎÒÃÇ¿ÉÒÔͨ¹ýÔÚappConsoleKernel.phpÎļþÖÐÌí¼Ó´úÂëÐÐÀ´ÊµÏÖÕâÒ»µã£º

protected $commands = [
    // ...
    AppConsoleCommandsSendMail::class,
    // ...
];

µÇ¼ºó¸´ÖÆ

ÔÚ½«×Ô½ç˵ÏÂÁî×¢²áµ½ArtisanÖ®ºó£¬ÎÒÃÇ¿ÉÒÔÔÚ¿ØÖÆ̨ÖÐʹÓÃËüÃÇ¡£ÀýÈ磬Ҫ·¢ËÍÒ»·â²âÊÔÓʼþ£¬ÎÒÃÇ¿ÉÒÔÔÚ¿ØÖÆ̨ÖÐÔËÐÐÒÔÏÂÏÂÁ

php artisan sendmail someuser@example.com

µÇ¼ºó¸´ÖÆ

Õ⽫Ïòsomeuser@example.com·¢ËÍÒ»·âµç×ÓÓʼþ£¬²¢ÔÚ¿ØÖÆ̨ÖÐÊä³öÀÖ³ÉÐÅÏ¢¡£

×ܽá

Laravel ArtisanÊÇLaravelÓ¦ÓóÌÐòµÄÖ÷Òª×é³É²¿·Ö£¬ËüÄܹ»×ÊÖúÎÒÃÇ¿ìËÙÌìÉú´úÂë¹Ç¼ÜºÍ±àд×Ô½ç˵ÏÂÁʹÓÃLaravel Artisan¾ÙÐÐÏÂÁîÐнçÃ濪·¢Äܹ»Ìá¸ßÎÒÃǵĿª·¢Ð§ÂÊ£¬½µµÍ´úÂë¹ýʧÂÊ£¬ÊÇÖµµÃÎÒÃÇȥѧϰºÍÕÆÎÕµÄÊÖÒÕ¡£

ÒÔÉϾÍÊÇLaravel¿ª·¢£ºÔõÑùʹÓÃLaravel Artisan¾ÙÐÐÏÂÁîÐнçÃ濪·¢£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ