×ðÁú¿­Ê±

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
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿