Laravel/Vagrant issue - php

I've got a school project and I pushed this to my bitbucket account.
A friend of me needs to pull this project to do some changes and other stuff.
The problem is, whenever he pulls the project and tries to open vagrant, there are no files in his "vagrant ssh".
We tried the 'composer install' for the vendor files.
We got another homestead.yaml file for launching vagrant but it still doesn't seem to fix our problem.
For my part everything works fine, but when my friend pulls the project localy he just can't seem to find any files in his 'vagrant ssh environment'

Homestead.yaml is there for binding the local storage to the virtual environment. Why doesnt he try to do the vagrant ssh first, and then do the pull request inside the shell?
EDIT:
Just try to do things in order. If he followed the instructions for the Laravel installation, his project folder should be something like C:/Project/PHP/Project_name and that route should be specified inside the homestead.yaml file like so:
folders:
- map: C:\Project\PHP
to: /home/vagrant/Code
So it says to bind PHP folder on local disk to virtual folder /code in vagrant.
After that create the project folder inside PHP folder, and pull the files inside, and modify the homestead.yaml once again to bind the project to browser like so:
sites:
- map: project_name.dev
to: /home/vagrant/Code/Project_name/public
And what is left is to modify hosts file to bind that name to the IP address:
192.168.10.10 project_name.dev

He should open the Homestead.yaml and check if the "folders" config reflects the mapping of the project on his machine.

Related

Move files from a docker container to an outside folder on the same server using php

I am fairly new to docker, please bear with me if its a basic question. I have a laravel project on a server, the project is dockerized. What I want to do is move a file from my project to another location on the same server that is not dockerized.
So, my project is setup on /var/www/my-project directory and I want to copy a file from my-project/storage/app/public/file.csv to /var/{destination_folder}. How can I do that in laravel? I think my issue is not related to laravel it is related to docker which is not allowing to move files out of it. Please don't add laravel or php file copy code snippets,I have tried plenty.
What I've tried?
1- I have tried copying file using:
Storage::disk('local')->put('/var/{destination_folder}', 'my-project/storage/app/public/file.csv' )
but, it does not copy the file.
2- I have also tried moving the file using bash script which I'm executing from my laravel controller using shell_exec or process but, it is also not working.
cp "/var/www/my-project/storage/app/public/file.csv" "/var/destination_folder"
What's hapening in this solution is that it is working when I run the command from terminal, but its not working when I call it from my controller and it gives me
cp: cannot create regular file '/var/destination_folder/file.csv': No such file or directory
After googling the above error it seemed that this is a permission issue wo, I changed the permission of the destination folder to 775 and I also checked the user from which I was running the laravel app and it gave me root when I ran whoami from the app.
Let me know how this could be achieved, thank you!
The entire point of docker is that it is isolated from the base host. You cannot simply copy the file out, as the docker host does not have access to any disk that is not mounted.
The easiest option is to create a destination directory and create a bind mount as per https://docs.docker.com/storage/bind-mounts/
You would then use the following argument for your docker run:
--mount type=bind,source=/var/destination_folder,target=/some_directory_inside_your_docker and copy the file to some_directory_inside_your_docker and it will appear in the parent host.
Another option is to generate a user account on the parent host, LOCK IT DOWN HARD for security reasons, and then have a private key inside your docker that would allow your docker to SSH to the parent host (note, this won't work with every network configuration). I don't think it's a good idea when you can do bind mounts, but it would work.

Laravel Homestead problems (Windows 10)

I've combed through similar threads, but none are quite the same issue. I've installed Homestead a handful of times now and seem to always have some kind of issue.
So I've created a www folder on my desktop and cloned the laravel/homsetead in there. I "cd" into www/Homestead and run "bash init.sh" but it created the .homestead hidden folder containing Homestead.yaml, after.sh, and aliases file in my Windows "Users" directory. I can copy/past the files into www/Homestead, edit the Homestead.yaml file accordingly, but then I get a slew of errors when I do vagrant up. Any idea why the init shell file points to that directory and how that could be effecting things?
I resolved this by cloning laravel/homestead in my user directory and adding a /Code folder. init.sh ran fine and vagrant up worked without issue.??????
NONO,it doesn't work for me

Laravel homestead directory is refusing to sync

I am having some trouble getting vagrant/homestead virtual machine to sync up with my real machine.
I am following the laravel homestead guide here: https://laravel.com/docs/5.2/homestead
I think the problem is due to my virtual machine having the directory "Code" and my real machine having the directory "code" (notice the uppercase 'C').
Here is the directories on my virtual machine...
and my yaml file directories
To be honest this is all very overwhelming and the tutorial is so unclear to me as a n00b.
So my question is simple, how to I change the upper-case Code directory on my virtual machine to a lower-case 'code'.
Many thanks in advance.
EDIT:
Here are the steps I am going through...
1: Update my Homestead.yaml as follows
2: I open that command prompt in the ~/Homestead directory and type in the following and nothing has changed!
You map the directories within the Homestead.yaml, under folders
folders:
- map: /Directory/to/your/pc/folder
to: /home/vagrant/code

Issues while taking Laravel project online

I am trying to take my Laravel project online. I am using AWS to host it. The project is working fine in localhost. But when I try to put it online, I have to add public at the end of URL to view my project. Plus, no other route except '/' is working for me. For example, I have a route defined user/login which is working fine in localhost but not online. Here is the link to the project.
You need to correctly set the document root on your web server. The document root is the folder that apache or nginx will attempt to serve files out of. You want this to be the full path to the Laravel public folder.
I'm not an AWS expert, but if you're using Elastic Beanstalk checkout the "Document root" section on this page. If you're just spinning up an EC2 instance you'll need to alter your deployment scripts to change the Apache virtual host setup and/or nginx configuration to point to the correct folder.
Add a Procfile to your project root that contains something like the following:
web: vendor/bin/heroku-php-apache2 public
The above assumes you are using php/apache, if it is something else, then change accordingly.

Laravel Homestead Serve code not creating and connecting to folder(s)

I have tried running the following code, and even though it runs and sets the nginx blocks ok, its not linking to the folder in question with in the host machine.
serve projects.dev /home/vagrant/Code/projects.dev
When i then list the folders within the Code folder on the guest machine, i only get the folders that were created via the automated Yaml config file on init set up.
It seems not be creating the folder and/or linking to it at all with between the guest and host machines
Running it on a iMac OS Mavericks.
Vagrant 1.6.2
VirtualBox 4.3.12
That is strange. What I have is I have a folder mapped on the "folders" section from my host machine that inside contains all the sub-folders for all my projects in progress. So my nginx sites just basically link to the sub-folders inside this directory. If you have something like that it "should" show you the folders from your host inside that Code directory in your VM. Maybe post your YAML file to check it out?
My problem was the new Homestead file, use small c for spelling directory "code".
I was upgrading my homestead, so the old code folder was using capital c, spelled "Code".
I just change my Homeastead.yaml file from calling "code" to "Code".

Categories