I've cloned this php project locally and run docker-compose up --build.
It seems the cloned code is not mapped to the docker environment. Even after deleting everything I can see that the project still works on the browser.
What am I doing wrong? As I have read here the default working directory is the path of the Compose file
Related
I'm using a vagrant box for my php project. I've created two .env files (.env and .env.testing). The website runs smoothly but while testing the functions using PHPUnit, it throws me a File Not found error. I can see the files on my directory but can't view them in terminal using ls. But I can see them all if I use ls -a command. Is the issue with vagrant or putty or am I doing this wrong?
I got a php project which is already done and for starters I have to put it up on a server (planning to use Heroku). I am new to PHP virtual boxes, Laravel, etc. The person who made the project recommended to use Laravel so I started to get things going that way. I am running on Windows 10 and using cmder as my terminal.
I downloaded VirtualBox & Vagrant.
Then using commander I added the Laravel/Homestead box
by doing:
vagrant box add laravel/homestead
in the folder c:\Users\Jacky\vagrant\ubuntu (At least I think that is where I added it)
Afterwards I believe I did
vagrant init
or vagrant init laravel/homestead
whatever I did afterwards I was able to run
vagrant ssh
and get into the system. There I was able to check and I had php and composer installed.
I then followed laravels instructions and created a homestead folder at c:\Jack\Homestead
ran git checkout for v7.19.2
ran init.bat
and configured the Homestead.yaml file
I made the following folder map
- map: C:\Jack\myapp\public
to: /home/vagrant/myapp
and the following site map
- map: myapp.test
to: /home/vagrant/myapp/public
I am a bit confused with the directory structure of this whole thing and not sure if I was supposed to put the myapp directory inside c:\Jack\Homestead\myapp or if just doing it like i did in c:\Jack\myapp is fine.
Anyways that still worked and I could see it in my web browser. So far all was good.
Then the project instructions told me to do the following
run composer install
There was an env.example file I had to change to .env and change some setting
run php artisan key:generate
run php artisan migrate --seed
run php artisan passport:install
run php artisan storage:link
At this point I got an error that the Symlink could not be created, so I googled and found in Stack Overflow to restart as admin. I ran cmder as admin and have been having a heart attack for the last 30 minutes since it told me I had to vagrant up and when I did so it couldnt find my box and even doing vagrant box list
I would get no results and it wanted to redownload which takes over 3 hours.
I just restarted without admin and I do find that my Laravel/Homestead box is listed so I assume it was installed for my user and not admin so I guess I cant run cmder as admin.
So now I am trying to connect again, I am not sure in which folder I should be running the vagrant commands but I only seem to have a VagrantFile in my C:\Jack\Homestead folder so if I run a vagrant command anywhere else it gives me an error that a vagrant environment is required, etc.
So I tried the following inside my homestead folder:
vagrant ssh - I get:
VM must be running to open SSH connection. Run `vagrant up to start the virtual machine.
(In my VirtualBox Manager i see my homestead-7 VM running though)
vagrant up - I get:
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'laravel/homestead'...
==> homestead-7: Matching MAC address for NAT networking...
==> homestead-7: Checking if box 'laravel/homestead' is up to date...
A VirtualBox machine with the name 'homestead-7' already exists.
Please use another name or delete the machine with the existing
name, and try again.
vagrant ssh 'homestead-7' I also get
VM must be running to open SSH connection. Run vagrant up
to start the virtual machine.
And the problem is once I do connect I assume I will still have the same problem running:
php artisan storage:link
So my questions are as follows:
Where should I have my projects myapp folder, should it be where it is at C:\Jack\myapp or am I supposed to put it in C:\Jack\Homestead\myapp
Is the VagrantFile supposed to be only in my Homestead folder and is that where I should be running all my Vagrant commands from? Like vagrant ssh and vagrant up
How do I connect again now that I am getting those errors running vagrant ssh and vagrant up
Once I connect I assume I will get the same error running php artisan storage:link since to run as administrator seems to not work what do I do?
I Assume that I should run git init and heroku create inside the myapp folder is this correct?
1) I always keep my apps folders outside of the Homestead folder. Your Homestead folder contains a git project, so if you put your apps inside you should include the folder in the .gitignore file. I think it's easier if you just put your apps elsewhere.
2) Vagrantfile is suposed to only be inside of your Homestead folder ( c:\Jack\Homestead). You should run all your vagrant commands inside the Homestead folder.
3) I used to get this error when I tried to run 'vagrant up' to a project that used the same box name 'homestead-7'. If you have version control, check if the file c:\Jack\Homestead\.vagrant\machines\homestead-7\virtualbox\id has been changed. If so, try restoring the old value and running 'vagrant up' again.
4) You are running in a windows environment, right? Windows can be a little temperamental with symlinks inside vagrant. You'll get the same problem if you try to npm install something. What I do to solve this is to run npm (and php artisan storage:link) outside of the virtual machine, in the host pc, inside the root of the app folder. Just a reminder: to do that you will need php installed in your host machine.
5) All commands related to the app (and not the virtual machine) should be run inside the virtual machine, in the folder app (ex: /home/vagrant/code/myapp) or inside the app folder of your host machine. Those two folders are in sync, thanks to vagrant.
I'm new to Laravel framework. I have installed and developed a small application. I've got source code from Github for an application which I want to integrate and run on my localhost. Please guide me any link or material where I get proper instructions to start working on this website. Give me details about which file to be edited so that atleast I can access on my localhost.
Github link : https://github.com/fakharkhan/laravel-school-erp
If you don't want to use homestead (which is somewhat complex for beginners to setup) follow this:
steps to setup laravel app from github repo
first of all you need to install git and composer.
open command prompt (terminal) in your document root folder.
clone the repository by executing git clone https://github.com/fakharkhan/laravel-school-erp.git
change directory in terminal to newly cloned project by using cd laravel-school-erp in your case.
run composer install to install project dependencies.
rename .env.example to .env file.
open .env file and enter the database connection information.
run laravel migrations (import database) by executing php artisan migrate from terminal.
visit the url by adding /public to it.
Optional
Setup virtual host by editing httpd-vhosts.conf file (so you can avoid typing /public in the url) and adding following to it
<VirtualHost example.dev:80>
DocumentRoot "C:/xampp/htdocs/laravel/public"
ServerName example.dev
</VirtualHost>
then edit your host file and add following to it:
127.0.0.1 example.dev
You can replace example.dev with whatever URL you like.
You can use Laravel Homestead
https://laravel.com/docs/5.4/homestead
Laravel Homestead is an official, pre-packaged Vagrant box that provides you a wonderful development environment without requiring you to install PHP, a web server, and any other server software on your local machine.
You should give a look on Laravel's documentation.
This the best way to understand Laravel.
If you just get the source code you'll need to do some things :
Copy .env.example and rename it .env
Edit .env file to fit on your needs like database informations
Run composer install to install dependencies
Run php artisan key:generate
Assuming you are using xampp on Windows as localhost. Now go to path/to/xampp/htdocs then open git terminal by right click on Git Bash Here
Now run following commands:
1. git clone https://github.com/fakharkhan/laravel-school-erp
2. cd laravel-school-erp
3. composer install
4. cp .env.example .env
5. php artisan key:generate
For database connection: make a database and set (DB_DATABASE, DB_USERNAME, DB_PASSWORD) values to .env file (which is in your project root).
And finally browse: localhost/laravel-school-erp/public
I know this might sound really silly, but I'm kinda stuck and need help. I'm trying to use Laravel 5.3 and use Homestead as my IDE. I have previously worked on PHP using NetBeans and XAMPP, but the installation has always been a pain. I have no formal training and have learnt and used basic PHP on my own for my webpages.
I'm running a Windows 8-32Bit OS & here's what I've done so far:
I have downloaded Laravel using Composer.
I have installed Virtual Box & Vagrant.
I have installed Git Bash and ran vagrant box add laravel/homestead (Homestead.yaml was not found in my Homestead folder after running bash init.sh command. I downloaded it from Github and added there).
Set SSH Key.
Ran vagrant up in Homestead folder (the installation was complete).
Issues:
If I just type http://localhost:8000 in my browser, nothing happens. I have to run php artisan serve in the command prompt inside laravel directory and keep the prompt window open for the default Laravel 5 page to open.
If I type http://127.0.0.1:8000 in my browser, nothing happens at all.
So how do I use Homestead then for my development everyday ?
you can try
localhost/project-name/public
if you dont want to run php artisan serve
I am trying to use Openshift for the first time to host a php site(PHP 5.4 cartridge) I am working on for a school project. I followed the directions here to push my existing repo to my gear, and can see that the code is on the gear by ssh-ing into the gear. What do I have to do now to host the website? I initially thought that I would just be able to see the index.php in my repo, but when I go to the provided url it is just a blank page. I think I may need to use the deploy action hook to cp the git repo somewhere, but not sure where. Any help would be appreciated.
With the PHP 5.4 cartridge the application root is the root of your application directory. Let me try and explain a bit further. If you create an application named "myphpapp" with the following command:
$> rhc app create myphpapp php-5.4
After the application is created, the git repository will be cloned to the directory you ran the create command. Change to that directory:
$> cd myphpapp
This is your application www root directory and is where you need to place files. For example, create a new test.php file like this:
$> echo "some php code" >> test.php
Add the file to your local git repository and then commit and push to your openshift server:
$> git add test.php
$> git commit -am "Adding a new file"
$> git push
When you run the git push command, the changes will be pushed to the remote git repository on the openshift server. Once the code is pushed, a hook on the server will see that a new file has been added to the repo and then deploy it to the www root on the openshift server. Once the deploy has finished, you can access the file by pointing to:
http://yourApp-yourDomain.rhcloud.com/test.php
Hope that helps.
--
gs
I did not read the documentation clearly enough. The root for the app is yourApp/php. So your repository has to have a php subdirectory inside of it, and that will be the app root. There is no need to copy your code from the repository to the root. As you have the correct structure, when you push your code the website will be live.