On my local machine I have created using homestead vagrant box a laravel project. Now I have an Homestead folder that contains many files like Vagrantfile, Homestead.yaml configuration and as soon as. I have also another folder sibling of Homestead folder that contain the Laravel files project. My question is how to share on Git this folders in order to clone the repository from another machine and recreate automatically the same Vagrant machine and the laravel project? In both folders there are composer.json files.Thanks in advance.
Depends on what you want to achieve. If you want to have a "frozen" in time vagrant box you would init homestead, let it do it's thing and them remove anything that's not mentioned in the vagrant file, then use that as a base for your repo. You can also fork homestead, run init and the use that as a base.
Homestead has an extra provisioning script, by convention named after.sh (see this for an example and this to see when it's called), which could clone your project from a separate repo into a place of your choosing (consistent with the project root you set up in your homestead file).
My point is -- don't mix development environment setup with your project files.
All of the above could be done under assumption you would have all the prerequisite software installed on your machine (vagrant, homestead, git, etc). Otherwise (maybe homestead would do it for you) you might also right a custom setup script that would check those dependencies, attempt to install them and the up the homestead box based on your configuration (something like a pre-init to init.sh :)). Or just put the instructions in the readme file (or link to Laravel's documentation).
I hope this helps!
Related
I want to deploy my Laravel project which has a Per-project Homestead inside it (not the global homestead). Some Vagrant and all Homestead files are included inside my Laravel project. This is the first time I'm deploying a Laravel application, and I really cannot find any information about files and folders that may be excluded from the deployment (Especially for a project with a per-project Homestead inside it).
I guess, .vagrant, tests, .env.example, .gitattributes, .gitignore, after.sh, aliases, Homestead.yaml, phpunit.xml, readme.md, and Vagrantfile files and folders may be excluded. Am I right? And what about the vendor folder (There are some Vagrant, Homestead files inside, as well, like e.g. homestead, homestead.bat inside the vendor/bin folder, or the whole homestead folder inside vendor/laravel).
Ideally, you would use a VPS or deployment server like DigitalOcean. However, as you stated you are using a shared server, the directories/files you will need to upload to the root directory of your server account are:
app/*
bootstrap/*
config/*
database/*
public_html/*
resources/*
routes/*
storage/*
vendor/*
.env
The remaining .files are for dependency management and development tests, and since you likely won't be using any build processes or Continuous Integration on a shared server, you won't need them.
Note: make sure these are in the root directory and the only publicly accessible directory is public_html. By default, shared hosting servers already have this restriction. Uploading the Laravel project as you have it will overwrite the website's current public_html directory, so make sure to back up anything you may have there currently.
Update
Frameworks like Laravel are designed to use root/command-line access to assist with deployment and server management. This is the advantage of frameworks. Shared servers do not typically allow users root access, so you end up having issues like yours, where deployment is a manual upload instead of a CLI command through version control.
vendor contains all of the dependencies your app is relying on to operate (Eloquent, Doctrine, Flysystem, etc.), so it won't work without the vendor directory.
You should deploy from version control, and by default that should exclude .vagrant and Homestead.yaml everything else is safe to leave in.
I'm still really new to Git version control and Laravel. But I have gotten so far, and I'm not sure now where I am going wrong.
I set up VirtualBox and Vagrant on my local windows machine and installed homestead successfully. I have managed to get my Laravel website (it's only one page at the moment as I learn things) working correctly, it displays the header and the footer and the images load and everything. So that's all good.
So now, I have my Laravel website set up within my virtual vagrant server. On this server, the directory for my website is:
/home/vagrant/Code/sites/public_html
No when I cd to that directory, I ran the following:
git init
get remote add origin https://user#repo/user/publichtml.git
git add *
git commit -m "Initial Commit"
git push -u origin master
(I've substituted user#repo instead of the real URL)
All went through successfully. Great. So now on my live server I ran the following:
cd /home/sites/public_html
git init
git clone https://user#repo/user/publichtml.git
Which again, worked fine. It downloaded all the files into the public_html directory which is great. So then I go to visit the website and this is what I get:
The only explanation for this happening is maybe I need to install something on the server before I clone these files to it. I guess the files in the Laravel folder won't run by themselves? Do I need to install composer and laravel on the server or something? If so, how do I do that, and why don't they run on their own?
I cannot see a .htaccess or index.php in the root directory so I am not sure how it runs anyway.
You should install Laravel using composer instead.
composer create-project laravel/laravel mysite
You should also point the document root on your web server to laravels "/public" folder, making the framework code reside outside of the document root. That's good for security (no one can access any framework code, like your configs etc directly).
You will then find the .htaccess-file in the /public folder.
Please read the Laravel documentation about the different but recommended ways to install Laravel.
Btw, doesn't homestead use Nginx instead of Apache? In that case, .htaccess isn't even used. Please refer to the Laravel documentation again regarding homestead.
You need to redirect traffic to public/index.php instructions for this are webserver dependent.
I've created a basic LAMP stack for my Vagrant box using Anisible. It's all working fine, etc and now I want members of my team to use the same box.
Vagrant recommends one Vagrant file per project, not a problem, but what about the provision resources, the playbooks, hosts, etc? I'm pretty sure they shouldn't be committed to that projects Git repo, so what do I do with them?
Do I commit them to a separate repo and simply clone them as a submodule?
If that's the case, should I include the Vagrant file as well or am I missing something?
Taking the submodule idea further, would it makes sense to create project-specific branches off this repo and clone them as a submodule or am I looking at this the wrong way?
Commit everything you need to bring up your box(es) for that project. You can easily copy and paste files from one project to another for reuse (or make a general repo) but the general idea would be that once they are committed to a project then all the developers needs to do is pull that project and vagrant up. If there are any mid-development changes, they can pull down again and vagrant provision and are current. That is the whole idea.
Check out the Github repos for Anisible, Chef and Puppet. The files are all there for their vagrant boxes per project.
Someone please describe how to work with vagrant? what i have done so far
I have installed Virtual Machine
Installed Vagrant
run few command and now Ubuntu 32 bit is installed in virtual machine
I have my project on github.
I make clone of the repository on my desktop ( D:)
created clone on my desktop
now my question is how to work with this repository code and associate vagrant?
Clearly no idea what this Vagrant actually is?
I think you have web project written in php. First you need to define vagrant folder. Clone your repository to the folder from your host machine. For folder in guest machine , let apache know where is you host. This is the step you need to do.
But I wanna suggest you to learn how vagrant work first. If you don't know the concept, it will not be ok. And you can use https://puphpet.com/ for vagrant configuration.
While installing laravel through terminal command, my other projects in MAMP htdocs folder got affected and they are not working.
I followed this process for installing laravel
Those directions have you symlink the "htdocs" directory to your laravel install, effectively making your htdocs directly useful only for Laravel.
You should avoid this, perhaps by creating a symlink from your laravel build to a directory within htdocs. For example, linking to a directory in htdocs called "mylaravelapp": ln -s /path/to/laravel-master /path/to/htdocs/mylaravelapp.
Lastly, consider using Vagrant or another virtual machine provider instead of MAMP for a server. You'll have to get through a learning curve (potentially), but you'll end up better for it. This creates a virtual server for you, which won't interact with any other parts of your Mac (YOu can make a server per project!).
Here is a guide to get started with Laravel 4 and Vagrant.