<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Ini｜林鼎淵 Dean Lin</title>
    <link>https://deanlin.net/tags/ini/</link>
    <image><url>https://deanlin.net/images/author_hu_aa256fc934e9a932.jpg</url><title>Ini｜林鼎淵 Dean Lin</title><link>https://deanlin.net/tags/ini/</link><width>144</width><height>144</height></image>
    <description>林鼎淵（Dean Lin）的部落格：生成式 AI 企業內訓講師、外商資安公司軟體專家、7 本書作者。400 多篇文章用白話分享生成式 AI 實戰、Claude Code 與 Vibe Coding 教學、團隊合作與職場成長。</description>
    <generator>Hugo</generator>
    <language>zh-tw</language>
    <copyright>© 2020–2026 林鼎淵 Dean Lin</copyright>
    <lastBuildDate>Tue, 16 Jun 2020 17:05:47 +0800</lastBuildDate>
    <atom:link href="https://deanlin.net/tags/ini/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Laravel常用指令</title>
      <link>https://deanlin.net/blog/202006/laravel-common-commands/</link>
      <pubDate>Tue, 16 Jun 2020 17:05:47 +0800</pubDate>
      <guid>https://deanlin.net/blog/202006/laravel-common-commands/</guid>
      <dc:creator>林鼎淵</dc:creator>
      <category>技術教學</category>
      <description>laravel有很多常用的指令，但有時候會忘記或是不想自己全部打完，那這篇文章就是你專門用來複製貼上的大補帖</description>
      <media:content url="https://deanlin.net/blog/202006/laravel-common-commands/images/laravel-common-commands-og_hu_9496b00eff300207.jpg" medium="image" type="image/jpeg" width="1200" height="675" />
      <content:encoded><![CDATA[<p><img src="https://deanlin.net/blog/202006/laravel-common-commands/images/laravel-common-commands-01.webp" width="1400" height="583" alt="Laravel常用指令（圖 1）" fetchpriority="high" decoding="async"></p>
<blockquote>
<p>這篇文章會列出我在使用Laraval框架時常用到的指令(部分是套件指令)</p>
</blockquote>
<h2 class="h-nomark" id="1-資料庫相關指令">1. 資料庫相關指令<a class="h-anchor" href="#1-%e8%b3%87%e6%96%99%e5%ba%ab%e7%9b%b8%e9%97%9c%e6%8c%87%e4%bb%a4" aria-label="這個段落的連結"></a></h2>
<p><strong>Migration 資料庫完全重新設定</strong></p>
<pre tabindex="0"><code>php artisan migrate:refresh — seed
</code></pre><p><strong>備份應用程式包括資料庫，<a href="https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/190804/">請確認是否已經安裝plugin</a></strong></p>
<pre tabindex="0"><code>php artisan backup:run
</code></pre><p><strong>備份的資料庫執行</strong></p>
<pre tabindex="0"><code>php artisan backup:run --only-db
</code></pre><p><strong>只需要備份的檔案</strong></p>
<pre tabindex="0"><code>php artisan backup:run --only-files
</code></pre><p><strong>database 還原</strong></p>
<pre tabindex="0"><code>mysql -u root -p database_name &lt; backup.sql
</code></pre><h2 class="h-nomark" id="2-安裝檔遺失相關issue">2. 安裝檔遺失相關issue<a class="h-anchor" href="#2-%e5%ae%89%e8%a3%9d%e6%aa%94%e9%81%ba%e5%a4%b1%e7%9b%b8%e9%97%9cissue" aria-label="這個段落的連結"></a></h2>
<p><strong>composer 全部砍掉重裝</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>rm -rf vendor/
</span></span><span style="display:flex;"><span>composer update -v
</span></span></code></pre></div><h2 class="h-nomark" id="3-laravel-常用指令">3. Laravel 常用指令<a class="h-anchor" href="#3-laravel-%e5%b8%b8%e7%94%a8%e6%8c%87%e4%bb%a4" aria-label="這個段落的連結"></a></h2>
<p><strong>創建model</strong></p>
<pre tabindex="0"><code>php artisan make:model Photo
</code></pre><p><strong>創建controller</strong></p>
<pre tabindex="0"><code>php artisan make:controller UserController
</code></pre><p><strong>創建migration</strong></p>
<pre tabindex="0"><code>php artisan make:migration create_users_table — table=users
</code></pre><p><strong>創建seeder</strong></p>
<pre tabindex="0"><code>php artisan make:seeder UsersTableSeeder
</code></pre><p><strong>創建middleware</strong></p>
<pre tabindex="0"><code>php artisan make:middleware CheckAge
</code></pre><p><strong>創建job</strong></p>
<pre tabindex="0"><code>php artisan make:job SendReminderEmail
</code></pre><p><strong>創建testcase</strong></p>
<pre tabindex="0"><code>php artisan make:test UserTest
</code></pre><h2 class="h-nomark" id="4-php相關指令">4. php相關指令<a class="h-anchor" href="#4-php%e7%9b%b8%e9%97%9c%e6%8c%87%e4%bb%a4" aria-label="這個段落的連結"></a></h2>
<p><strong>尋找php.ini</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo find / -name ‘php.ini’
</span></span></code></pre></div><p><strong>更改php相關設定(如果遇到nginx 502也能用這個重啟嘗試看看)</strong></p>
<pre tabindex="0"><code>vi /etc/php/7.3/fpm/php.ini
service php7.3-fpm restart
</code></pre><h2 class="h-nomark" id="5-單元測試">5. 單元測試<a class="h-anchor" href="#5-%e5%96%ae%e5%85%83%e6%b8%ac%e8%a9%a6" aria-label="這個段落的連結"></a></h2>
<pre tabindex="0"><code>./vendor/bin/phpunit
// 如果使用sudo權限來做測試，部分storage會變成admin權限，這個指令可以讓整個資料夾回歸www-data權限
chown -R www-data:www-data storage/
</code></pre><h2 class="h-nomark" id="6-排程相關">6. 排程相關<a class="h-anchor" href="#6-%e6%8e%92%e7%a8%8b%e7%9b%b8%e9%97%9c" aria-label="這個段落的連結"></a></h2>
<p><strong>排程重啟supervisor</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#e6edf3;background-color:#0d1117;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>// 檔案位置
</span></span><span style="display:flex;"><span>/etc/supervisor/conf.d
</span></span><span style="display:flex;"><span>// 每次修改需要執行這幾個指令重啟<span style="color:#ff7b72;font-weight:bold">(</span>開啟<span style="color:#ff7b72;font-weight:bold">)</span>
</span></span><span style="display:flex;"><span>sudo supervisorctl reread
</span></span><span style="display:flex;"><span>sudo supervisorctl update
</span></span><span style="display:flex;"><span>sudo supervisorctl start laravel-worker:*
</span></span><span style="display:flex;"><span>sudo supervisorctl restart laravel-worker:*
</span></span></code></pre></div><p><strong>本機local端測試排程job</strong></p>
<p>下面幾種job為我個人將每個排程進行分類，讓需要較長時間的排程不會影響到其他短時間能完成的排程</p>
<pre tabindex="0"><code>php artisan queue:work — queue=small_job,default — timeout=600 — delay=3 — sleep=3 — tries=3
php artisan queue:work — queue=big_job,default — timeout=7200 — delay=3 — sleep=3 — tries=3
php artisan queue:work — queue=default — delay=3 — sleep=3 — tries=3
</code></pre><h2 class="h-nomark" id="7-查看錯誤訊息">7. 查看錯誤訊息<a class="h-anchor" href="#7-%e6%9f%a5%e7%9c%8b%e9%8c%af%e8%aa%a4%e8%a8%8a%e6%81%af" aria-label="這個段落的連結"></a></h2>
<p>如果為 php 的錯誤訊息</p>
<pre tabindex="0"><code>vi /var/log/php7.3-fpm.log
</code></pre><p>如果為 Laravel 的錯誤訊息</p>
<pre tabindex="0"><code>vi project_path/storage/logs/laravel-xxx-xx.log
</code></pre><blockquote>
<p>從 log 就能推斷出大部分的問題，並取得查詢的關鍵字</p>
</blockquote>
]]></content:encoded>
    </item>
  </channel>
</rss>
