未加星标

Automating Laravel Homestead On Windows

字体大小 | |
[系统(windows) 所属分类 系统(windows) | 发布者 店小二04 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

I recently switched back to running windows from Ubuntu on my work computer. When I was running Ubuntu I used a fork of Laravel Valet which worked great. Now that I’m back on Windows I knew I wanted to setup Homestead again since I had issues running the Windows fork of Valet due to DNS configuration at my office.

I decided that I’d setup Homestead and try to automate creating a new site as much as possible. Since I’m becoming more and more familiar with the terminal I decided to use Git Bash to do most of my terminal work and it’s what I’ll be using to get this automated.

The Goal

My objective was to pull down a git repo (or install a new laravel project) and run a command that would do the following:

Add a site entry to my Homestead.yaml file Add a database entry to my Homestead.yaml file Add a IP entry to my hosts file Re-provision my Vagrant Homestead box so the new entries are updated How To GetThere Install Git, Vagrant, Homestead

These are obviously necessary for this tutorial. Each site has great instructions for each so I won’t cover that here.

Git Vagrant Homestead Hosts File

Windows doesn’t let you edit the hosts file ( c:\windows\system32\drivers\etc )without authenticating. My solution was to give myself full control of the file. Just right click on the hosts file, go to security, click the edit button, click your username, and check the box in the ‘Allow’ column for Full Control.


Automating Laravel Homestead On Windows
Hopefully your employer doesn’t restrictthis Bash Git Bash doesn’t automatically create the .bashrc or .bash_profile file. So the first step for us is to create those files in your user folder ( c:\users\[yourusernamehere] ).

Once you’ve created those files we’ll want to edit the .bashrc file. I’ve created a function that does all the work for me. You’ll need to change my username (vlm) with yours. But the two functions below will allow the magic to happen.

Usage

So at this point you’ve gotten everything setup and now it’s time for the magic. Here is the process you’ll use:

Pull down your repo or create a new project Change into that new directory Run hsadd

Yep, that is it! You can open up your Homestead.yaml and hosts files and see the entries.

P.S.

I also use two other functions in my bash.rc file to make things go faster. One is a function that starts up my homestead box, and the other is just a quick alias for Sublime Text so I can open it from the command line using subl . Here is my full .bashrc file:

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

主题: WindowsLaravelGitUbuntu
分页:12
转载请注明
本文标题:Automating Laravel Homestead On Windows
本站链接:http://www.codesec.net/view/520852.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(48)