{"id":1513,"date":"2025-02-11T19:18:01","date_gmt":"2025-02-11T11:18:01","guid":{"rendered":"https:\/\/blog.nonot.cn\/?p=1513"},"modified":"2025-02-11T19:18:06","modified_gmt":"2025-02-11T11:18:06","slug":"laravel%e8%87%aa%e5%b8%a6%e7%9a%84%e5%90%8e%e5%8f%b0laravel-admin%e5%ae%89%e8%a3%85%e8%bf%87%e7%a8%8b%e9%97%ae%e9%a2%98%e5%92%8c%e8%af%a6%e8%a7%a3%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/blog.nonot.cn\/index.php\/2025\/02\/11\/laravel%e8%87%aa%e5%b8%a6%e7%9a%84%e5%90%8e%e5%8f%b0laravel-admin%e5%ae%89%e8%a3%85%e8%bf%87%e7%a8%8b%e9%97%ae%e9%a2%98%e5%92%8c%e8%af%a6%e8%a7%a3%e8%ae%b0%e5%bd%95\/","title":{"rendered":"Laravel\u81ea\u5e26\u7684\u540e\u53f0laravel-admin\u5b89\u88c5\u8fc7\u7a0b\u95ee\u9898\u548c\u8be6\u89e3\u8bb0\u5f55"},"content":{"rendered":"<p>Laravel-admin\u53ef\u4ee5\u5feb\u901f\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u540e\u53f0\uff0c\u65b9\u4fbf\u5feb\u901f\u5f00\u53d1\u3002\u4ee5\u4e0b\u5185\u5bb9\u8bb0\u5f55\u7b80\u5355\u4f7f\u7528laravel-admin\uff0c\u4ee5\u53ca\u9047\u5230\u5c0f\u9519\u8bef\u7684\u89e3\u51b3\u65b9\u6cd5\u3002Laravel-admin \u4f9d\u8d56\u4ee5\u4e0b\u73af\u5883Nginx+PHP+MYSQL+Composer\uff0c\u9700\u8981\u63d0\u524d\u88c5\u597d(\u5b89\u88c5\u7684Laravel-admin\u7248\u672c\u4e3a1.8.19)\uff0cPHP\u3001Composer\u9700\u8981\u8bbe\u7f6e\u597d\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>1.\u901a\u8fc7 Composer \u5b89\u88c5Laravel\u6846\u67b6<br \/>\n\u5982\u679c\u4f60\u7684\u672c\u5730\u64cd\u4f5c\u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86 PHP \u548c Composer\uff0c\u8fd8\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7 Composer \u547d\u4ee4\u6765\u5b89\u88c5 Laravel \u5e94\u7528\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 Artisan CLI \u547d\u4ee4\u00a0serve\u00a0\u542f\u52a8 Laravel \u672c\u5730\u5f00\u53d1\u670d\u52a1\u5668\uff1a<\/p>\n<p>composer create-project laravel\/laravel Laravel-demo<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1531\" title=\"444df6459858ed104ec615e01ba896e26aa41d\" src=\"https:\/\/blog.nonot.cn\/wp-content\/uploads\/replace\/c706e828478815530fc992fdc6629dde.png\" alt=\"444df6459858ed104ec615e01ba896e26aa41d\" width=\"1129\" height=\"635\" \/><\/p>\n<p>cd Laravel-demo<\/p>\n<p>php artisan serve<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1530\" title=\"082cb0970818344e082779cb027ea920f3e46c-1\" src=\"https:\/\/blog.nonot.cn\/wp-content\/uploads\/replace\/0f91b24725477c4733e4947bf533a82c.png\" alt=\"082cb0970818344e082779cb027ea920f3e46c-1\" width=\"1129\" height=\"635\" \/><\/p>\n<p>\u6d4f\u89c8\u5668\u6253\u5f00\u00a0http:\/\/127.0.0.1:8000\/\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u6210\u529f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1532\" title=\"e33865740342a0c4df5517120ecb046c86ced5-1-1\" src=\"https:\/\/blog.nonot.cn\/wp-content\/uploads\/replace\/9b4cb93482826e2f81269e40d58ba706.png\" alt=\"e33865740342a0c4df5517120ecb046c86ced5-1-1\" width=\"1184\" height=\"593\" \/><\/p>\n<p>\u5982\u679c\u4e0d\u80fd\u663e\u793a\u8fd9\u4e2a\u754c\u9762\uff0c\u8bf7\u68c0\u67e5\u662f\u5426\u6f0f\u6389\u4e86\u4e0a\u9762\u67d0\u4e2a\u6b65\u9aa4\u3002<\/p>\n<p>2.\u65b0\u5efaLaravel\u6570\u636e\u5e93<br \/>\n\u4f7f\u7528\u6570\u636e\u5e93\u7ba1\u7406\u8f6f\u4ef6\u65b0\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\uff1alaravel\uff08\u81ea\u5df1\u968f\u610f\u53d6\u540d\uff09\uff0c\u6570\u636e\u5e93\u5efa\u597d\u540e\uff0c\u6253\u5f00Laravel-demo\u76ee\u5f55\uff0c\u4fee\u6539\u8be5\u76ee\u5f55\u4e0b\u7684.env\u6587\u4ef6\uff0c\u4fee\u6539\u914d\u7f6e\u6570\u636e\u5e93\u53c2\u6570:DB_DATABASE\uff08\u6570\u636e\u5e93\u540d\uff09\uff0cDB_USERNAME\uff08\u6570\u636e\u5e93\u8d26\u53f7\uff09\uff0cDB_PASSWORD\uff08\u6570\u636e\u5e93\u5bc6\u7801\uff09<\/p>\n<p>DB_CONNECTION=mysql<\/p>\n<p>DB_HOST=127.0.0.1<\/p>\n<p>DB_PORT=3306<\/p>\n<p>DB_DATABASE=laravel<\/p>\n<p>DB_USERNAME=root<\/p>\n<p>DB_PASSWORD=root<\/p>\n<p>&nbsp;<\/p>\n<p>3.\u901a\u8fc7 Composer \u5b89\u88c5Laravel-admin<br \/>\n\u5b98\u65b9\u6587\u6863\u5730\u5740\uff1a\u00a0https:\/\/laravel-admin.org\/<\/p>\n<p>\u9996\u5148\u786e\u4fdd\u5b89\u88c5\u597d\u4e86laravel\uff0c\u5e76\u4e14\u6570\u636e\u5e93\u8fde\u63a5\u8bbe\u7f6e\u6b63\u786e\u3002<\/p>\n<p>composer require encore\/laravel-admin:1.*<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1533\" title=\"198c8930655e19b7c596587a734d95c3864b9c-1-1-1\" src=\"https:\/\/blog.nonot.cn\/wp-content\/uploads\/replace\/0f33bd59eda78f2ea6763335dc45cf28.png\" alt=\"198c8930655e19b7c596587a734d95c3864b9c-1-1-1\" width=\"1129\" height=\"635\" \/><br \/>\n\u7136\u540e\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u6765\u53d1\u5e03\u8d44\u6e90\uff1a<\/p>\n<p>php artisan vendor:publish &#8211;provider=&#8221;EncoreAdminAdminServiceProvider&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1534\" title=\"7798d898515f99208de406ab7f6e24cd3dfe05-1-1-1-1\" src=\"https:\/\/blog.nonot.cn\/wp-content\/uploads\/replace\/d922a9c4766bba3917572d6e70b1d2a1.png\" alt=\"7798d898515f99208de406ab7f6e24cd3dfe05-1-1-1-1\" width=\"1129\" height=\"635\" \/><br \/>\n\u5728\u8be5\u547d\u4ee4\u4f1a\u751f\u6210\u914d\u7f6e\u6587\u4ef6config\/admin.php\uff0c\u53ef\u4ee5\u5728\u91cc\u9762\u4fee\u6539\u5b89\u88c5\u7684\u5730\u5740\u3001\u6570\u636e\u5e93\u8fde\u63a5\u3001\u4ee5\u53ca\u8868\u540d\uff0c\u5efa\u8bae\u90fd\u662f\u7528\u9ed8\u8ba4\u914d\u7f6e\u4e0d\u4fee\u6539\u3002<\/p>\n<p>\u7136\u540e\u8fd0\u884c\u4e0b\u9762\u7684\u547d\u4ee4\u5b8c\u6210\u5b89\u88c5\uff1a<\/p>\n<p>php artisan admin:install<\/p>\n<p>*\u8fd0\u884c\u8fd9\u4e2a\u547d\u4ee4\u7684\u65f6\u5019\uff0c\u5982\u679c\u9047\u5230\u4e86\u4e0b\u9762\u7684\u9519\u8bef:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1535\" title=\"c7059c8988fc89a3c7f0417dedd7ae4aa9830e-1-1-1-1-1\" src=\"https:\/\/blog.nonot.cn\/wp-content\/uploads\/replace\/c0eb2bdff09bad9c4fcad17967141ff3.png\" alt=\"c7059c8988fc89a3c7f0417dedd7ae4aa9830e-1-1-1-1-1\" width=\"1129\" height=\"635\" \/><\/p>\n<p>SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter tableusersadd uniqueusers_email_unique(email))<\/p>\n<p>\u53c2\u8003\u8fd9\u4e2aissue\u6765\u89e3\u51b3\u00a0\u00a0https:\/\/github.com\/z-song\/laravel-admin\/issues\/1541<\/p>\n<p>\u4e0a\u9762\u7684\u7f51\u7ad9\u6253\u4e0d\u5f00\u5c31\u76f4\u63a5\u770b\u8fd9\u91cc\u89e3\u51b3\u65b9\u6cd5:<\/p>\n<p>\u4fee\u6539laravel-demo\/app\/Providers\u76ee\u5f55\u4e0b\u7684AppServiceProvider.php\u6587\u4ef6:<\/p>\n<p>&lt;?php<\/p>\n<p>namespace AppProviders;<\/p>\n<p>use IlluminateSupportServiceProvider;<br \/>\nuse IlluminateSupportFacadesSchema; \/\/add fixed sql<\/p>\n<p>class AppServiceProvider extends ServiceProvider<br \/>\n{<br \/>\n\/**<br \/>\n* Bootstrap any application services.<br \/>\n*<br \/>\n* @return void<br \/>\n*\/<br \/>\npublic function boot()<br \/>\n{<br \/>\nSchema::defaultStringLength(191); \/\/add fixed sql<br \/>\n}<\/p>\n<p>\/**<br \/>\n* Register any application services.<br \/>\n*<br \/>\n* @return void<br \/>\n*\/<br \/>\npublic function register()<br \/>\n{<br \/>\n\/\/<br \/>\n}<br \/>\n}<\/p>\n<p>\u518d\u8fdb\u5165\u6570\u636e\u5e93\u7ba1\u7406\u8f6f\u4ef6\u5c06laravel\u6570\u636e\u5e93\u91cc\u9762\u7684\u8868\u5168\u5220\u9664\uff0c\u518d\u6267\u884c\u547d\u4ee4<\/p>\n<p>php artisan admin:install<\/p>\n<p>\u5982\u679c\u6ca1\u6709\u9047\u5230\u9519\u8bef\uff0c\u5219\u65e0\u9700\u4fee\u6539\u6587\u4ef6\u4e5f\u65e0\u9700\u6267\u884c\u547d\u4ee4\u3002\u81f3\u6b64\uff0cLaravel-admin\u5df2\u7ecf\u5b89\u88c5\u5b8c\u6210\u3002\u8fd0\u884c\u547d\u4ee4php artisan serve\uff0c\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u6253\u5f00\uff1ahttp:\/\/127.0.0.1:8000\/admin\/auth\/login \u8bbf\u95ee\u8fdb\u5165\u540e\u53f0\u3002\u8d26\u53f7\u53ca\u5bc6\u7801\u4e3a\uff1aadmin\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel-admin\u53ef\u4ee5\u5feb\u901f\u6784\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u540e\u53f0\uff0c\u65b9\u4fbf\u5feb&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1541,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1513","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/1513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1513"}],"version-history":[{"count":1,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/1513\/revisions"}],"predecessor-version":[{"id":1542,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/posts\/1513\/revisions\/1542"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media\/1541"}],"wp:attachment":[{"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.nonot.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}