1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
"use strict";(self.webpackChunklaradock_documentation=self.webpackChunklaradock_documentation||[]).push([[924],{8453:(e,n,r)=>{r.d(n,{R:()=>c,x:()=>i});var o=r(6540);const s={},t=o.createContext(s);function c(e){const n=o.useContext(t);return o.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:c(e.components),o.createElement(t.Provider,{value:n},e.children)}},8578:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>c,default:()=>h,frontMatter:()=>t,metadata:()=>i,toc:()=>d});var o=r(4848),s=r(8453);const t={sidebar_position:2,title:"Getting Started"},c=void 0,i={id:"getting-started",title:"Getting Started",description:"Requirements",source:"@site/docs/getting-started.md",sourceDirName:".",slug:"/getting-started",permalink:"/docs/getting-started",draft:!1,unlisted:!1,editUrl:"https://github.com/laradock/laradock/tree/master/DOCUMENTATION/docs/getting-started.md",tags:[],version:"current",sidebarPosition:2,frontMatter:{sidebar_position:2,title:"Getting Started"},sidebar:"tutorialSidebar",previous:{title:"Introduction",permalink:"/docs/Intro"},next:{title:"Usage",permalink:"/docs/usage"}},a={},d=[{value:"Requirements",id:"requirements",level:2},{value:"Installation",id:"installation",level:2},{value:"A) Setup for Single Project",id:"a-setup-for-single-project",level:3},{value:"A.1) Already have a PHP project:",id:"a1-already-have-a-php-project",level:3},{value:"A.2) Don't have a PHP project yet:",id:"a2-dont-have-a-php-project-yet",level:3},{value:"B) Setup for Multiple Projects:",id:"b-setup-for-multiple-projects",level:3},{value:"Usage",id:"usage",level:2}];function l(e){const n={a:"a",blockquote:"blockquote",code:"code",em:"em",h2:"h2",h3:"h3",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.h2,{id:"requirements",children:"Requirements"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"https://git-scm.com/downloads",children:"Git"})}),"\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.a,{href:"https://www.docker.com/products/docker-desktop/",children:"Docker"})," [ >= 19.03.0 ]"]}),"\n"]}),"\n",(0,o.jsx)(n.h2,{id:"installation",children:"Installation"}),"\n",(0,o.jsx)(n.p,{children:"Choose the setup the best suits your needs."}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.a,{href:"#A",children:"A) Setup for Single Project"}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"#A1",children:"A.1) Already have a PHP project"})}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"#A2",children:"A.2) Don't have a PHP project yet"})}),"\n"]}),"\n"]}),"\n",(0,o.jsx)(n.li,{children:(0,o.jsx)(n.a,{href:"#B",children:"B) Setup for Multiple Projects"})}),"\n"]}),"\n",(0,o.jsx)("a",{name:"A"}),"\n",(0,o.jsx)(n.h3,{id:"a-setup-for-single-project",children:"A) Setup for Single Project"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsx)(n.p,{children:"(Follow these steps if you want a separate Docker environment for each project)"}),"\n"]}),"\n",(0,o.jsx)("a",{name:"A1"}),"\n",(0,o.jsx)(n.h3,{id:"a1-already-have-a-php-project",children:"A.1) Already have a PHP project:"}),"\n",(0,o.jsx)(n.p,{children:"1 - Clone laradock on your project root directory:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"git submodule add https://github.com/Laradock/laradock.git\n"})}),"\n",(0,o.jsxs)(n.p,{children:["Note: If you are not using Git yet for your project, you can use ",(0,o.jsx)(n.code,{children:"git clone"})," instead of ",(0,o.jsx)(n.code,{children:"git submodule "}),"."]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsxs)(n.em,{children:["To keep track of your Laradock changes, between your projects and also keep Laradock updated ",(0,o.jsx)(n.a,{href:"/docs/usage#track-your-laradock-changes",children:"check these docs"})]})}),"\n",(0,o.jsx)(n.p,{children:"2 - Make sure your folder structure should look like this:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"* project-a\n* laradock-a\n* project-b\n* laradock-b\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.em,{children:"(It's important to rename the laradock folders to unique name in each project, if you want to run laradock per project)."})}),"\n",(0,o.jsxs)(n.p,{children:["3 - Go to the ",(0,o.jsx)(n.a,{href:"#Usage",children:"Usage"})," section."]}),"\n",(0,o.jsx)("a",{name:"A2"}),"\n",(0,o.jsx)(n.h3,{id:"a2-dont-have-a-php-project-yet",children:"A.2) Don't have a PHP project yet:"}),"\n",(0,o.jsx)(n.p,{children:"1 - Clone this repository anywhere on your machine:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"git clone https://github.com/laradock/laradock.git\n"})}),"\n",(0,o.jsx)(n.p,{children:"Your folder structure should look like this:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"* laradock\n* project-z\n"})}),"\n",(0,o.jsx)(n.p,{children:"2 - Edit your web server sites configuration."}),"\n",(0,o.jsxs)(n.p,{children:["We'll need to do step 1 of the ",(0,o.jsx)(n.a,{href:"#Usage",children:"Usage"})," section now to make this happen."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"cp .env.example .env\n"})}),"\n",(0,o.jsxs)(n.p,{children:["At the top, change the ",(0,o.jsx)(n.code,{children:"APP_CODE_PATH_HOST"})," variable to your project path."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"APP_CODE_PATH_HOST=../project-z/\n"})}),"\n",(0,o.jsxs)(n.p,{children:["Make sure to replace ",(0,o.jsx)(n.code,{children:"project-z"})," with your project folder name."]}),"\n",(0,o.jsxs)(n.p,{children:["3 - Go to the ",(0,o.jsx)(n.a,{href:"#Usage",children:"Usage"})," section."]}),"\n",(0,o.jsx)("a",{name:"B"}),"\n",(0,o.jsx)(n.h3,{id:"b-setup-for-multiple-projects",children:"B) Setup for Multiple Projects:"}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsx)(n.p,{children:"(Follow these steps if you want a single Docker environment for all your projects)"}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:["1 - Clone this repository anywhere on your machine (similar to ",(0,o.jsx)(n.a,{href:"#A2",children:"Steps A.2. from above"}),"):"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"git clone https://github.com/laradock/laradock.git\n"})}),"\n",(0,o.jsx)(n.p,{children:"Your folder structure should look like this:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"* laradock\n* project-1\n* project-2\n"})}),"\n",(0,o.jsxs)(n.p,{children:["Make sure the ",(0,o.jsx)(n.code,{children:"APP_CODE_PATH_HOST"})," variable points to parent directory."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"APP_CODE_PATH_HOST=../\n"})}),"\n",(0,o.jsx)(n.p,{children:"2 - Go to your web server and create config files to point to different project directory when visiting different domains:"}),"\n",(0,o.jsxs)(n.p,{children:["For ",(0,o.jsx)(n.strong,{children:"Nginx"})," go to ",(0,o.jsx)(n.code,{children:"nginx/sites"}),", for ",(0,o.jsx)(n.strong,{children:"Apache2"})," ",(0,o.jsx)(n.code,{children:"apache2/sites"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["Laradock by default includes some sample files for you to copy ",(0,o.jsx)(n.code,{children:"app.conf.example"}),", ",(0,o.jsx)(n.code,{children:"laravel.conf.example"})," and ",(0,o.jsx)(n.code,{children:"symfony.conf.example"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["3 - change the default names ",(0,o.jsx)(n.code,{children:"*.conf"}),":"]}),"\n",(0,o.jsxs)(n.p,{children:["You can rename the config files, project folders and domains as you like, just make sure the ",(0,o.jsx)(n.code,{children:"root"})," in the config files, is pointing to the correct project folder name."]}),"\n",(0,o.jsxs)(n.p,{children:["4 - Add the domains to the ",(0,o.jsx)(n.strong,{children:"hosts"})," files."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{children:"127.0.0.1 project-1.test\n127.0.0.1 project-2.test\n...\n"})}),"\n",(0,o.jsxs)(n.p,{children:["If you use Chrome 63 or above for development, don't use ",(0,o.jsx)(n.code,{children:".dev"}),". ",(0,o.jsx)(n.a,{href:"https://laravel-news.com/chrome-63-now-forces-dev-domains-https",children:"Why?"}),". Instead use ",(0,o.jsx)(n.code,{children:".localhost"}),", ",(0,o.jsx)(n.code,{children:".invalid"}),", ",(0,o.jsx)(n.code,{children:".test"}),", or ",(0,o.jsx)(n.code,{children:".example"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["4 - Go to the ",(0,o.jsx)(n.a,{href:"#Usage",children:"Usage"})," section."]}),"\n",(0,o.jsx)("a",{name:"Usage"}),"\n",(0,o.jsx)(n.h2,{id:"usage",children:"Usage"}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"Read Before starting:"})}),"\n",(0,o.jsxs)(n.p,{children:["If you are using ",(0,o.jsx)(n.strong,{children:"Docker Toolbox"})," (VM), do one of the following:"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:["Upgrade to ",(0,o.jsx)(n.a,{href:"https://www.docker.com/products/docker-desktop/",children:"Docker Desktop"})," for Mac/Windows (Recommended). Check out ",(0,o.jsx)(n.a,{href:"/docs/usage/#upgrading-laradock",children:"Upgrading Laradock"})]}),"\n",(0,o.jsxs)(n.li,{children:["Use Laradock v3.*. Visit the ",(0,o.jsx)(n.a,{href:"https://github.com/laradock/laradock/tree/LaraDock-ToolBox",children:"Laradock-ToolBox"})," branch. ",(0,o.jsx)(n.em,{children:"(outdated)"})]}),"\n"]}),"\n",(0,o.jsx)("br",{}),"\n",(0,o.jsx)(n.p,{children:"We recommend using a Docker Engine version which is newer than 19.03.0."}),"\n",(0,o.jsx)("br",{}),"\n",(0,o.jsxs)(n.blockquote,{children:["\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Warning:"})," If you used an older version of Laradock it's highly recommended to rebuild the containers you need to use ",(0,o.jsx)(n.a,{href:"/docs/usage/#Build-Re-build-Containers",children:"see how you rebuild a container"})," in order to prevent as much errors as possible."]}),"\n"]}),"\n",(0,o.jsx)("br",{}),"\n",(0,o.jsxs)(n.p,{children:["1 - Enter the laradock folder and copy ",(0,o.jsx)(n.code,{children:".env.example"})," to ",(0,o.jsx)(n.code,{children:".env"})]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-shell",children:"cp .env.example .env\n"})}),"\n",(0,o.jsxs)(n.p,{children:["You can edit the ",(0,o.jsx)(n.code,{children:".env"})," file to choose which software's you want to be installed in your environment. You can always refer to the ",(0,o.jsx)(n.code,{children:"docker-compose.yml"})," file to see how those variables are being used."]}),"\n",(0,o.jsxs)(n.p,{children:["Depending on the host's operating system you may need to change the value given to ",(0,o.jsx)(n.code,{children:"COMPOSE_FILE"}),". When you are running Laradock on Mac OS the correct file separator to use is ",(0,o.jsx)(n.code,{children:":"}),". When running Laradock from a Windows environment multiple files must be separated with ",(0,o.jsx)(n.code,{children:";"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["By default the containers that will be created have the current directory name as suffix (e.g. ",(0,o.jsx)(n.code,{children:"laradock_workspace_1"}),"). This can cause mixture of data inside the container volumes if you use laradock in multiple projects. In this case, either read the guide for ",(0,o.jsx)(n.a,{href:"#B",children:"multiple projects"})," or change the variable ",(0,o.jsx)(n.code,{children:"COMPOSE_PROJECT_NAME"})," to something unique like your project name."]}),"\n",(0,o.jsxs)(n.p,{children:["2 - Build the environment and run it using ",(0,o.jsx)(n.code,{children:"docker-compose"})]}),"\n",(0,o.jsx)(n.p,{children:"In this example we'll see how to run NGINX (web server) and MySQL (database engine) to host a PHP Web Scripts:"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"docker-compose up -d nginx mysql\n"})}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Note"}),": All the web server containers ",(0,o.jsx)(n.code,{children:"nginx"}),", ",(0,o.jsx)(n.code,{children:"apache"})," ..etc depends on ",(0,o.jsx)(n.code,{children:"php-fpm"}),", which means if you run any of them, they will automatically launch the ",(0,o.jsx)(n.code,{children:"php-fpm"})," container for you, so no need to explicitly specify it in the ",(0,o.jsx)(n.code,{children:"up"})," command. If you have to do so, you may need to run them as follows: ",(0,o.jsx)(n.code,{children:"docker-compose up -d nginx php-fpm mysql"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["You can select your own combination of containers from ",(0,o.jsx)(n.a,{href:"https://laradock.io/introduction/#supported-software-docker-images",children:"this list"}),"."]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsxs)(n.em,{children:["(Please note that sometimes we forget to update the docs, so check the ",(0,o.jsx)(n.code,{children:"docker-compose.yml"})," file to see an updated list of all available containers)."]})}),"\n",(0,o.jsx)("br",{}),"\n",(0,o.jsx)(n.p,{children:"3 - Enter the Workspace container, to execute commands like (Artisan, Composer, PHPUnit, Gulp, ...)"}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"docker-compose exec workspace bash\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.em,{children:"Alternatively, for Windows PowerShell users: execute the following command to enter any running container:"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-bash",children:"docker exec -it {workspace-container-id} bash\n"})}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Note:"})," You can add ",(0,o.jsx)(n.code,{children:"--user=laradock"})," to have files created as your host's user. Example:"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-shell",children:"docker-compose exec --user=laradock workspace bash\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsxs)(n.em,{children:["You can change the PUID (User id) and PGID (group id) variables from the ",(0,o.jsx)(n.code,{children:".env"})," file)"]})}),"\n",(0,o.jsx)("br",{}),"\n",(0,o.jsx)(n.p,{children:"4 - Update your project configuration to use the database host"}),"\n",(0,o.jsxs)(n.p,{children:["Open your PHP project's ",(0,o.jsx)(n.code,{children:".env"})," file or whichever configuration file you are reading from, and set the database host ",(0,o.jsx)(n.code,{children:"DB_HOST"})," to ",(0,o.jsx)(n.code,{children:"mysql"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-env",children:"DB_HOST=mysql\n"})}),"\n",(0,o.jsxs)(n.p,{children:["You need to use the Laradock's default DB credentials which can be found in the ",(0,o.jsx)(n.code,{children:".env"})," file (ex: ",(0,o.jsx)(n.code,{children:"MYSQL_USER="}),").\nOr you can change them and rebuild the container."]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsxs)(n.em,{children:["If you want to install Laravel as PHP project, see ",(0,o.jsx)(n.a,{href:"#Install-Laravel",children:"How to Install Laravel in a Docker Container"}),"."]})}),"\n",(0,o.jsx)("br",{}),"\n",(0,o.jsx)(n.p,{children:"5 - Open your browser and visit your localhost address."}),"\n",(0,o.jsx)(n.p,{children:"Make sure you add use the right port number as provided by your running server."}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.a,{href:"http://localhost",children:"http://localhost"})}),"\n",(0,o.jsxs)(n.p,{children:["If you followed the multiple projects setup, you can visit ",(0,o.jsx)(n.code,{children:"http://project-1.test/"})," and ",(0,o.jsx)(n.code,{children:"http://project-2.test/"}),"."]})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(l,{...e})}):l(e)}}}]); |