Search code examples
laraveldevelopment-environmentenvironment

Configure Laravel environment just once and use it for further app developments


I am pretty new to Laravel and just started with development of my first application in the framework. I had started learning it a while ago and faced n number of issues while configuring the test application. It had been a long time and I can't find all the notes I had made while I faced issues.

So my problem is this time I want to configure my environment and create a package or a container so that I get it up and running next time when I want to develop more apps in future. Is there any way to achieve it?


Solution

  • If you want a clean and complete development environment for laravel and spare yourself of configuring everything on your local OS and Be able to have the same configuration somewhere else on another machine, I'd recommend using homestead which you can find it's documentation Here.

    Steps are easy you basically install vagrant and VirtualBox or VMWare. (I recommend VirtualBox). Then install homestead by following the Per Project Installation section of the docs and you're gonna have a Homestead.yaml file in your laravel installation. Which is going to look something like this :

    ---
    ip: "192.168.10.10"
    memory: 2048
    cpus: 1
    hostname: myhost
    name: myhost
    provider: virtualbox
    
    authorize: ~/.ssh/id_rsa.pub
    
    keys:
        - ~/.ssh/id_rsa
    
    folders:
        - map: "/Path/To/Project/myapp"
          to: "/home/vagrant/myapp"
    
    sites:
        - map: my.app
          to: "/home/vagrant/myapp/public"
    
    databases:
        - mydatabase
    # blackfire:
    #     - id: foo
    #       token: bar
    #       client-id: foo
    #       client-token: bar
    # ports:
    #     - send: 50000
    #       to: 5000
    #     - send: 7777
    #       to: 777
    #       protocol: udp
    

    Edit this file to your settings and save it for future use. Then just add my.app *Your.Ip.Add.ress* to your OS hosts file which you're gonna find the guide on how to do that in the docs as well.

    Finally run vagrant up in your project root and have everything setup! Just type my.app or whatever you set it up to be and your laravel website comes up.

    You can ssh to this virtual server installation with vagrant ssh command. Database username is homestead and password is secret by default. you can change all of this yourself in the virtual server.