YiChia
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    運用 docker 架設 laravel 的開發環境 === 前言 - docker 為快速部署環境而生,所以安裝前無須裝設任何伺服器管理工具、或者 composer 等laravel 相關開發套件 安裝 DOCKER - * 系統需求 * 開啟VT-X :::info 要安裝Windows下的boot2docker,必須確定你的電腦CPU有支援VT-X,但這並不是Docker需要的,而是VirtualBox需要的,可使用CPU-Z來檢查。另外也必須到BIOS中確定VT-X有開啟,如果都OK的話,即可直接安裝 ::: * win7 64-bit 位元 或者win7以上版本 * win7 1. 開啟電腦的 VT-X (待補 須找到一台未開啟VT-X的電腦重裝一次) - 安裝 Speccy - 電腦資訊檢視軟體 - 3. 官網下載 docker toolbox 點此下載[DockerToolbox](https://docs.docker.com/toolbox/toolbox_install_windows/) 4. 安裝 DockerToolbox.exe - 開啟安裝 ![安裝初始畫面](https://imgur.com/lMG3IJC.png) - 預設額外安裝項目 ![安裝初始畫面](https://imgur.com/E2yH5dI.png) Boot2docker ~ 是一個專門在Mac及Windows下使用Docker的套件 - 勾選所需的軟體、套件 ![安裝初始畫面](https://imgur.com/6oBJ55z.png) 1. docker compose :透過單一命令來啟動多個 container 執行你定義的 service 2. VirtualBox 3. Kitematic for Windows(Alpha) : Docker的GUI介面 4. git __已有安裝 VirtualBox 或 git 可以不用勾選,安裝前須先關閉該服務__ - 準備安裝 ![安裝初始畫面](https://imgur.com/7oPKwA2.png) - 安裝中 ![安裝初始畫面](https://imgur.com/glXpLNm.png) - 安裝完成 ![安裝初始畫面](https://imgur.com/m3ZzZGH.png) - 顯示安裝位置 ![安裝初始畫面](https://imgur.com/N6rJmzt.png) 9. 啟動Docker - 點擊 Docker Quickstart Terminal ->右鍵->以系統管理員身分執行 ![link text](https://imgur.com/nKVkVJq.png) *同時會建立 .docker 到預設的根目錄 ,下載 boo2docker.iso* - Docker安裝成功 ,顯示 Docker icon 及 預設IP ![安裝初始畫面](https://imgur.com/T3oUOE1.png) 10. 驗證安裝結果 ,在 Docker Quickstart Terminal 下指令 `docker -v` 檢視docker版本 `docker-compose -v` 檢視 docker-compose 版本 ![安裝初始畫面](https://imgur.com/Hro1m6i.png) __額外說明 : docker預設根目錄為 c/Users/20170703(個人AD資料夾)__ * win10 (待補) 架設Laravel開發環境 - * 到 git 上面下載laravel 專案到自己的本機位置 [git專案位置](https://github.com/EricChenExosite/laravel5_6) ![git clone project](https://imgur.com/HE8xwIW.png) *建議安裝在 預設目錄 c://Users/個人AD帳號/ 底下,可再往下開設資料夾* * 打開 Docker quick start, 進入 專案目錄,顯示資料夾內資料 ``` cd c://Users/20170703/dockerLaravel/laravel5_6 ls ``` ![](https://imgur.com/aR2Nytq.png) 圖中可看到 docker-compose.yml 檔,此檔定義了此專案所需要的各個容器的配置,詳細內容會在 docker的簡易說明 解釋,目前我們只需透過 docker-compose 的指令,將配置好的docker服務運行起來 * 運行配置好的docker服務 `docker-compose up -d` (up:啟動環境設定 -d :背景執行) ![docker-compose up -d](https://imgur.com/bj4OCz9.png) *安裝過程會有點久,可以暫離座位休息一下* 安裝好後會出現 Creating 容器名稱 ...done 的文字 我們可透過 `docker ps` 或者打開 Kitematic 查看目前 docker 內 container運行狀況 常用的 docker-compose 指令 - **docker-compose up -d** 啟動容器 - **docker-compose stop** 停止容器 - **docker-compose down** 關閉容器 * 查看容器運行狀態 - **docker ps** 查看目前運行狀態 ![docker ps](https://imgur.com/rtkUmlx.png) | CONTAINER ID | IMAGE| COMMAND | CREADTED| STATUS| POARTS|NAMES| | ------------ | ---- | ------- | --------| ------| ----- |-----| | 容器ID | 映像檔名稱 | 命令列 | 容器啟動時間| 狀態| 連接埠| 名稱| -- Kitematic (Docker GUI 操作介面) ![kitematic](https://imgur.com/ZKCayjQ.png) 運行中的容器會顯示在介面左邊 :::warning 注意 : kitematic 並不會即時更新,也沒有更新容器狀態的按鈕,所以都要關閉後再重啟 ::: 容器運行完成後,我們將會進行下一個步驟,初始化Laravel 專案,以及安裝Laravel所需要的套件 Laravel初始化設定 - * 安裝composer * 以下將針對composer是否安裝的狀態 ,分為已安裝和未安裝的執行方式 * 未安裝過composer docker 將 php 的套件管理工具 composer 轉換成 images的形式,所以需要以一般建立映像檔的方式來安裝 - 進入專案目錄,在容器內安裝composer然後掛載到本機的當前目錄上 ``` docker run --rm -v $(pwd):/app composer/composer install ``` ![install composer ](https://imgur.com/zyzUvUs.png) 完成後,用composer 來安裝此專案所需套件 `composer install` ![composer install](https://i.imgur.com/gStB2nQ.png) * 已安裝過,重新執行 `composer update` 來更新與此專案相依的套件 如遇到本機PHP與專案PHP(7.2.10)版本不符,需要在本機端下載相同的php版本,並且重新設定 php的環境變數(待補設定畫面) Laravel 建立資料表和 顯示資料 - 功能說明 - [ ] 建立User的資料表 - [ ] 運用 db seeder建立假資料 - [ ] 在網頁上顯示 **目前的開發環境為Docker,所以我們必須要進入到container內來執行 php artisan 的指令** ##### docker 指令介紹 `docker-compose exec app bash` 在docker 運行該容器內的指令 #### 1. 設定資料表、假資料 專案本身預設已有建立 Users 的table ,所以這個步驟我們只需要建立 UsersTableSeeder來設定假資料的內容 `docker-compose exec app php artisan make:seeder UsersTableSeeder` ![create seeder](https://i.imgur.com/Fc5KGMd.png) 開啟編輯器,填入自己要建立的資料 資料夾路徑: laravel5_6\database\seeds\UsersTableSeeder.php ![create seeder](https://i.imgur.com/sAZ8wGU.png) 在DatabaseSeeder 呼叫 UsersTableSeeder 資料夾路徑: laravel5_6\database\seeds\DatabaseSeeder.php ![make seed](https://i.imgur.com/3lEDRjU.png) #### 2. 產生資料表並且建立假資料到DB ``` docker-compose exec app php artisan migrate:refresh --seed ``` ![make seed](https://i.imgur.com/U7YFkGH.png) 連線到 DB,可看到 資料庫 Homestead 底下有建立 資料表 migrations,和 Users的資料表,而且已有預設的資料 ![make seed](https://i.imgur.com/7NN1sHh.png) ![make seed](https://i.imgur.com/TNibkZT.png) #### 2. 建立Controller `docker-compose exec app php artisan make:controller MyController` ![make:controller](https://i.imgur.com/ZPDdQrH.png) #### 3. 設定路由 資料夾路徑: laravel5_6\app\Http\Controllers\MyController.php ![設定路由](https://i.imgur.com/ucsRSPV.png) #### 4. web端顯示資料 ![show data](https://i.imgur.com/UuxbGfU.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully