Setting up Laravel Homestead with existing project - Laravel commands not recognized - laravel

I am setting up homestead on my mac.
I have made sure that the settings are right on my storage folder.
I have installed composer on the vagrant box.
If I navigate to /home/vagrant/Code then my code is there.
Here is my yaml file:
folders:
- map: ~/Sites/MYAPP/
to: /home/vagrant/Code
sites:
- map: my.app
to: /home/vagrant/Code/public
The output is just the standard "Something went wrong"
The console log shows a 500 error with a failure to load resource.
Am I doing something wrong?
I want to see the errors, so where is the .env file to turn those on?
Do I need to touch the Homestead.yaml file on vagrant?
What level of the structure does the "folders" portion of the yaml file need to be set to? Is the folder level that houses the entire laravel application? The public folder?
Is there a full explanation somewhere of all the parameters involved in setting this up? - Especially a postgres database?
Update :
Echoing out a "here" in the index.php function worked, but using a dd() produced an error - Call to undefined function dd().
It appears that the vagrant machine is not recognizing Laravel commands. Any suggestions?
Second Update:
Well, I got it working. How? I am not sure. The .env file was misnamed to .env.example so I changed that, but it didn't seem to do anything. I added homestead to the composer file - as that was mentioned in some forums but no in the install docs - and nothing seemed to happen. Then, it just started working. Frustrating.
Thanks

You should try to restart your Vagrantbox with the --provision flag and see if that helps.
If not, try changing the APP_DEBUG to true in your .env if you haven't already to see if you get some kind of stack-trace that can help you further.
Otherwise you should try placing dd() och log in the public/index.php to see how far it's running and if you can locate what's failing that way.

Your yaml is wrong. Should look like this..
folders:
- map: ~/Sites
to: /home/vagrant/Sites
sites:
- map: my.app
to: /home/vagrant/Sites/MYAPP/public

Related

Homestead.test default file gives [No input file specified] Ubuntu

I just installed Ubuntu 17.10 and I want to try create a website using Laravel, but I hit a rock, I followed the instructions. step by step on the official website. But I think something is missing,
Because I haven't touch / edit anything in Homestead.yaml, so basically it would working right?
I already use vagrant up --provision. already create the ssh key. I already googled it and try several ways but it doesn't fix it, I already turn on my XAMPP as well
Sorry but I never touched Ubuntu before, so I'm very blind using this OS
Here is my Homestead.yaml file
Homestead.yaml
and the directories of /home/workspace/ and /home/workspace/Homestead/
~ Dir
Homestead Dir
my Hosts file
Hosts File
EDITED:
I just create a new project in ~/Homestead/Projects/[it goes here] because the default laravel installation is working already, so now I want to create a new project in Projects folder inside Homestead, but why it redirect the url to https?
The folders
in this screenshot: https://i.stack.imgur.com/4cxGy.png Your ~/code folder appears to not exist, which means Homestead will not map it. Create that folder in your Host OS (Ubuntu 17) and then run vagrant destroy && vagrant up If you still have issues post the entire output here for us to check.
For my last question, why when I tried to open my new projects is always giving me this error your internet connection is not private. it's because I'm using .app or .dev in the of the site name, the problem is from google chrome, so I need changed it to .test then it's working perfectly.
I got the answer from this site
https://laracasts.com/discuss/channels/laravel/chrome-blocked-localhost-with-error-your-connection-is-not-private

'No input file specified' - Laravel Homestead

I'm having this message when trying to access to my app in Laravel 5. I have been trying to solve it following different ideas I have seen in this forum and others. It seems like is a problem in my Homestead.yaml file, but I cannot find where my error is. That is what I have in my Homestead.yaml:
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: testing1.app
to: /home/vagrant/Code/testing1/public
I also added this line to my 'hosts':
192.168.10.10 testing1.app
Any idea what could I do?
Thanks in advance!!
At First, please make sure your local directory is: Code which is in /home, where you will keep all of your Laravel app and it's mapping to VM's directory /home/vagrant/Code
Now, make sure your Laravel app inside testing1 and it's inside Codedirectory.
Now command: vagrant reload --provision
During configure Homestead.yaml never use tab key for space, instead use spacebar
Finally, Please let me know which OS you are using?

Laravel Homestead vhost configuration

I am using Laravel homestead. For a project I need a special vhost configuration, where should I define this?
You add a new folder mapping into the "sites" block of Homestead.yml, like so:
- map: myapp.com
to: /home/vagrant/Code/myapp/public
That's all there is to adding a new vhost. To modify it, edit the appropriate file in /etc/nginx/sites-available. In the above case, this would be /etc/nginx/sites-available/myapp.com
See here for example customization of a newly added vhost. Note that the quick tip linked here uses Homestead Improved, a slightly enhanced version of Homestead, as described here.
More Homestead related posts can be found on our site via the Homestead tag.
I have been looking for a solution for customizing nginx vhosts. You want to do it in provisioning, or better: after provisioning otherwise Homestead will overwrite any changes you have done manually to the vhost files.
One solution is the one I found here:
https://laracasts.com/discuss/channels/requests/homestead-provision-deletes-custom-nginx-settings
Basically you create configuration files in a folder in the host machine, map that extra folder to the vagrant machine, then in your after.sh file (which is run by homestead after the normal provisioning is finished) you just copy all of them to nginx's sites_available folder.

Laravel Homestead: 403 forbidden on nginx

I just installed Laravel Homestead according to their instructions. When I open http://homestead.app:8000 I get the nginx 403 forbidden HTTP Response.
I have tried setting app/storage permissions to 755, but that didn't work, so I reloaded Vagrant. With no further result.
I also tried changing the nginx configuration, but with no success.
I had the same problem and for me the cause was that in the Homestead.yaml file, I have incorrectly put this:
sites:
- map: homestead.app
to: /home/vagrant/Code
Instead of the correct syntax:
sites:
- map: homestead.app
to: /home/vagrant/Code/path/to/public
Another reason for this response can be duplicating your routing with folders in public directory. For example you might have homestead.app/lists GET route and lists folder in your /public directory. This will cause the same 403 error (server will assume you are trying to access /public/lists directory instead of your /lists route).
OK, i got the answer to the question after few hours of searching and debugging.
The problem:
I've got GET route /admin
Also i've got /public/admin/ folder with assets inside.
And i've got 403 access denied from nginx cause of this duplication;
So, if you don't want to rename route or assets folder, all you need to do is replace
location / {
try_files $uri $uri/ /index.php?$query_string;
# ^^^^^
}
with this:
location / {
try_files $uri /index.php?$query_string;
}
If you could rename your route or assets folder without any refactor then you could do this without nginx config fixing.
Hope this will be helpful.
I have been banging my head against the wall dealing with this very same problem, and I just solved it for my case.
I was sure I'd set up the yaml file correctly, but I kept getting the 403 error, and when experimenting with some routes I was getting "input file not specified".
My solution came from http://laravel.com/docs/4.2/homestead and it involved using the serve command. I wasn't adding any additional sites, just trying to anything to get the first site running.
SSH'ing into my vagrant box and using the command "serve my_app_name.app /home/vagrant/Code/path/to/public" did the job. Note that I had already put an entry into my hosts file for this app.
Hope this helps someone.
For some people this may be as simple as having git cloned in an existing public folder, e.g:
- map: hello-world.dev
to: /home/vagrant/Code/Laravel/public/hello-world
The correct folder structure is:
- map: hello-world.dev
to: /home/vagrant/Code/hello-world/public
Another good note is ignoring the laravel docs on editing hosts file, using git shell, or cygwin (windows) to install vagrant hostsupdater, and simply adding entries for hosts and aliases to ~/.homestead/Homestead.yaml file.
I would suggest checking the nginx logs - use sudo tail /var/log/nginx/homestead.app-error.log
Here's the full solution steps:
run homestead edit
add /public to the end of your directory
sites:
- map: homestead.app
to: /full/path/to/the/laravel-app/public
run homestead halt && homestead up --provision
Change the config of Nginx
Put that line in 'location /' section:
try_files $uri $uri/public/index.php?$query_string;
If its not working then replace your 'public' with the folder name that content 'index.php',
That worked great with me using ServerPilot,
Good luck!.
In my case, for testing purposes I had only phpinfo.php file in the public directory. The server kept showing 403 errors until I placed a file named index.php into the public folder!
In your case, you are getting nginx 403 forbidden HTTP Response because of improper configuration of sites in Homestead.yaml,
if you configure it properly it should work.
How to solve the issue step by step:
1) Goto your vagrant box and create the laraval app
$vagrant ssh
$cd ~/code
$#lets create basic blog
$laravel new blog
Crafting application...
Loading composer repositories with package information
........
$cd blog
$ll
# You should be able to see public folder in this dir.
# this is the entry point for your application.
# this is your public dir: ~/code/blog/public
# more explicitly: /home/vagrant/code/blog/public
$exit # exit ssh
2) Update the Homestead.yaml with proper site info
- map: homestead.app
to: /home/vagrant/code/blog/public # should be same as in step1
3) Re-provision your vagrant
$vagrant reload --provision
You should be able to access it now using http://homestead.app
Thank you!
I ran into this when I tried manually creating my first site. #GregD's answer helped me discover the problem! Vagrant/Homestead/Laravel will typically get everything running smoothly on its own if you use the built-in features.
Homestead's configuration file comes preconfigured for one site, located in /Code/Laravel/. Some steps to get this test bed up and running:
Install Homestead (remember to set your hosts file)
vagrant up and connect to your virtual machine via ssh (Chrome Secure Shell is great if you don't have a terminal on your machine already)
Download and set up the PHAR package
cd ~/Code
laravel new Laravel.
Browse to http://homestead.app:8000
This will create your first site with appropriate permissions. You can model future sites after the permissions on this one, or just use the "sites" node of Homestead.yaml and laravel new <site> to make new sites in the future.
Access in your browser
homestead.app/public
Before installation of laravel/laravel with composer within /home/vagrant/Code/Laravel/public
Configuring Nginx Sites :
sites:
- map: homestead.test
to: /home/vagrant/project1/public
To fix, ssh into your homestead, then do :
nano /etc/nginx/sites-available/the-name-of-your-project.test
After that all you need to do is get rid of $uri/ that you will find in the location object , then do vagrant reload and error should be fixed.
My solution was to move the address in the host file to the bottom of the file. It happend to me twice.
Check nginx error in you vagrant box
vagrant ssh
sudo cat var/log/nginx/yoursite.tld-error.log
"*1 FastCGI sent in stderr: "Unable to open primary script: /home/vagrant/code/public/index.php (No such file or directory)" "
Change in Homestead.yaml
nano Homestead.yaml
to
map: homestead.app
to: /home/vagrant/code/Laravel/public
then..
vagrant reload --provision

Laravel 4 debugging not working

It's extremely frustrating that I have 'debug' => true in the app config but all Laravel is showing is "Whoops, looks like something went wrong." For the love of coding, does somebody know how to get debugging to work?
I have faced the same problem. Laravel was showing only "Whoops, looks like something went wrong." but this line and not showing the actual error. Then I have checked the app/config/app.php file and changed "debug" => false to "debug" => true and it worked perfectly.
You said that you have also done it and still not working. I suggest you to run a composer update command for your project and then try again.
To be sure your app is in development mode, edit bootstrap/start.php, in the detectEnvironment function simply put your machine name. On linux use hostname terminal commande to determine your machine name.
$env = $app->detectEnvironment(array(
'local' => array('homestead', 'Jeanphi'),
));
Actually debugging is working fine for me with L4.0.7 when i set 'debug' => true in app/config/app.php
That switch tells Laravel to turn on Whoops and to bypass the 'compiled.php' file. When it is disabled, Whoops will not show. A normal server error page is served instead.
Were you expecting something else?
EDIT: maybe you are referring to "debugging" as the old profiler bar that were in L3 (Anbu). In that case I suggest you install this package
Check you haven't renamed your app/config folder as fideloper suggests in the comment.
For example you might have renamed it to prevent overwriting the default config settings when copying your site somewhere else.
For all it's worth, I was getting this error now after deployment because I didn't create these folders:
/app/storage/cache
/app/storage/logs
/app/storage/meta
/app/storage/sessions
/app/storage/views
Some changes need an apache restart to take effect.
I came across problem recently, after separating out debug and a few other config options into a separate (dev.php) config file.
The in-hindsight obvious, by-logic obscure solution: Don't move debug out of config/app.php
Had that same problem altought my app was in debug mode.
In my case I was deploying on server,and to make that work
you must take care of detectEnvironment variable.
It is located in bootstrap/start.php
$env = $app->detectEnvironment(array(
'local' => array('your_server_name'),
));
as it's instructed in the docs :
http://laravel.com/docs/4.2/configuration
i got same problem with that...
first, laravel run well on windows using apache..
then while i'm using ubuntu and nginx, it shows "Whoops, looks like something went wrong."
no error in php log and nothing found on laravel log..
so i tried modify path folder permission to 0777
sudo chmod -R 0777 {put your folder application folder here}
it works
I had the same problem several times and I have two possibilities.
the folder storage doesn't have the right permissions, you should use chmod 755 or chmod 777
the public/index.php has none permission or a 777
These two options has occurred to me before, maybe there are some more.
well you need to clear configuration cache and regenerate it each time you change config files
run 'php artisan config:cache' in console and your good to go

Resources