Laravel Homestead (Windows) how to add vendor to PATH - laravel

I've set up my Homestead and i am able to connect via vagrant ssh.
I also add Laravel installer over Composer via composer global require laravel/installer.
But know, i don't know how to make it work cause in the vagrant user folder, there is no .composer/vendor folder. i figured out that the composer has installed the vendor folder under /root/.composer but when i try to access, i don't have permission cause it's in root folder.
My goal is to use the Laravel installer. For that, i need to add the path to the $PATH. Here the guideline from the docu:
Make sure to place the $HOME/.composer/vendor/bin directory (or the equivalent directory for your OS) in your $PATH so the laravel executable can be located by your system
But i can't do that in vagrant or at least i don't know how.
And yes, i know that composer is installed, that part worked.
So how can i make it work?

I fixed it.
For all others with the same issue: i need to run as administrator and i also had an outdated vagrantbox

Related

I can't install composer globally in my web host, how can I use the "composer" command?

I hosted my website on french host Gandi, with their simple hosting plan.
I cannot move anything in the /usr/local/bin directory since it is read-only, so I used to manage with composer.phar, which works well.
I recently used a library which requires the composer executable to be present (This library executes something like "composer require xxx" and there is no fallback to composer.phar).
Is there a way to make it work ?
What I have done so far :
Tried to install composer globally (Failed because of the read-only filesystem)
Tried to install composer globally for the current user (Failed because there was no ~/.local/bin directory, and also failed after creating the directory and restarting the instance)
Tried to move the file to any directory of the $PATH variable (Failed because all of these directories are read-only)
Tried to rename composer.phar to composer, and allowed it to be executable chmod +x composer (Failed because it only works with the command ./composer and not with composer)
Ok, I finally succeeded with the following steps:
renamed composer.phar to composer mv composer.phar composer
made this new file executable chmod +x composer
added the current path (corresponding to my website's root) to the system's $PATH variable export PATH=$PATH:$PWD
I'm not fully satisfied with this since this relies on a specific website's root folder, but hey, it works! I'll try to update this answer if I find a way to create a folder available for every website I'll host there.

composer installation using composer not working

I am trying to install laravel using composer
composer global require "laravel/installer"
but i get
I just finished reinstall my windows 7, before that laravel installation was always succesful and now it is not.. maybe someone know how solve this problem?
According to Laravel's Documentation
Make sure to place the $HOME/.composer/vendor/bin directory (or the equivalent directory for your OS) in your $PATH so the laravel executable can be located by your system.
In case of Windows you should ad that $PATH to your enviornment variables.

Integrating Vagrant and PHPStorm with Composer/PHPCS using Remote Interpreter via Shared Folders?

I'm using a Vagrant VM created by Puphpet, running Ubuntu 14.04 for the purpose of developing a Wordpress site. I use Composer to manage PHP dependencies, and Composer is installed automatically as a system service via Puphpet, so there is no .phar file, just an executable Composer file in /usr/local/bin/composer.
I also use PHPStorm as my main IDE, and love its Remote Interpreter feature. So far, PHPUnit is the only feature that supports it, as Composer and PHP Codesniffer requires having a local PHP interpreter installed in order to be used. This kind of defeats the purpose of the Composer/PHP Codesniffer tools within PHPStorm when used with Vagrant. Jetbrains claims they have no plans to add this feature in the near future.
Which leads me to my question- Would it be possible to set up a shared folder to the PHP executable file in my VM, and use that as my Remote Interpreter in the Composer Settings window?
Could I also do the same to my PHPCS executable file path in the Code Sniffer settings panel with PHPStorm?
The only one I wouldn't be able to set up a Shared Folder to is the composer.phar file which is needed to run the Composer tool within PHPStorm, because there is no composer.phar file within my VM, as its just an executable in /usr/local/bin/composer as I described earlier. So would the solution be to download a composer.phar file to somewhere within my host directory? Will this interfere the Composer install on the VM?
*Update: As Sven has explained to me, the Composer file in /usr/local/bin/composer is the composer.phar file. I kind of understood this, but still am not sure if a. PHPStorm will recognize it as such, and b. if creating a shared folder will even work.
I added images of the settings panels so you can understand what I'm talking about.
Thanks, let me know if you need anymore info.

Confusing step in the Laravel Homestead installation process?

I'm going through the Laravel Homestead setup, but a particular instruction seems to be completely out of context/unexplained. I'm not at all familiar with composer, having only used npm for package management in the past.
In the 'Installing Homestead' section, under With Composer + PHP Tool it reads:
Once the box has been added to your Vagrant installation, you are ready to install the Homestead CLI tool using the Composer global command:
composer global require "laravel/homestead=~2.0"
Make sure to place the ~/.composer/vendor/bin directory in your PATH so the homestead executable is found when you run the homestead command in your terminal.
http://laravel.com/docs/4.2/homestead
Emphasis mine. What does this mean? What ~/.composer/vendor/bin directory? What PATH? Feels like it's missing a step!
Updating the PATH variable is slightly out of the spec of the Laravel docs as its something you should do for composer, but regardless I too think Laravel should at least link through to a resource of how to go about it.
Create/edit your ~/.bash_profile, add the following
export PATH=~/.composer/vendor/bin:$PATH
finally run source ~/.bash_profile to update your environment
I wrote a blog on this which goes into a little more detail http://blog.iwader.co.uk/updating-path-environment-variable-osx-and-unix-systems/

How to install Laravel via Laravel Installer on Windows?

I’m trying to install the Laravel Framework on Windows with the Laravel Installer method.
In the documentation I found the following:
First, download the Laravel installer using Composer. Make sure to
place the “~/.composer/vendor/bin” directory in your PATH so the
laravel executable is found when you run the laravel command in your
terminal.
Now this PATH does not look familiar to me. Could you tell me the working path for Windows?
BTW: I’m using WAMP. Composer is installed and updated.
The PATH for Windows:
I’ve found the location where composer stores the Vendor files.
So instead of ~/.composer/vendor/bin, on Windows the following path should be used:
C:\Users\<COMPUTER NAME>\AppData\Roaming\Composer\vendor\bin
How to install the Laravel Installer:
=======
I assume you have php and composer in your PATH already.
First of all install the Laravel Installer. Open a command prompt and enter:
composer global require "laravel/installer=~1.1"
**Then update the PATH environment variable** via e.g. command prompt with admin privileges:
set PATH=%PATH%;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
// setx /M path "%path%;%appdata%\Composer\vendor\bin" (this may destroy your system)
%appdata% is added, so you don’t have to worry about adding your computer name.
How to create a fresh Laravel Installation:
Now you should be able to run laravel commands in the command prompt.
To create a fresh laravel installation, open a command prompt in the directory of choice and enter:
laravel new name_of_directory
If everything went right, you should see the following message:
Crafting application...
Application ready! Build something amazing.
Use Laragon (http://laragon.org/)
Install Laragon.
Use Laragon Menu to create project
Take you 5 minutes to have Laravel4 o Laravel5.
Launch Laragon Project
Laragon automatically create Virtual host for your project name ( project_name.me)
Hope it helps.
Source: https://innopy.wordpress.com/2015/02/07/laravel-windows/
If you are having trouble using the command prompt, use the GUI approach:
The path in Windows is:
C:\Users\UserName\AppData\Roaming\Composer\vendor\bin
In the above path "UserName" is your user name that you are logged in your computer as. If you don't know your username, go here: http://library.queensu.ca/libguides/computers/windows-username-check.htm
Copy the above path, replace the "UserName" with your username.
Then go to your computer's environment variables. Here's how:
Right click on your Computer and go to properties
Go to Advanced system settings
Under Advanced Tab, Click on Environment Variables
Under User Variables, select Path and click Edit:
Put a semicolon at the end of the existing text and paste your path, example:C:\ProgramData\ComposerSetup\bin. Press OK ...
Restart your command prompt and type laravel and hit enter. If the path was successfully set, you will see "Laravel Installer Version ... "
How to install Laravel on Windows using WAMP
Install WAMP first.
I leave everything to default.
Enable OpenSSL and all required extensions in PHP.ini
After you installed WAMP, you need to do this. This is how you make sure OpenSSL is enabled:
On your right hand side of your taskbar, click WAMP and then choose PHP.ini.
And then find php_openssl, and then remove the semicolon in front of php_openssl.
And then, save. Close that file and now go to wamp manager again, and now enable OpenSSL there just to be safe.
After you do that, restart Wamp.
Install Composer
Go to https://getcomposer.org/ and download Windows installer.
The setup will ask for your PHP. if you install your WAMP in default setting, it will usually end up in C:\wamp\bin\php\php5.4.12.
If your installation is successful, by running composer on command prompt, you will see all kinds of info just by running that command.
If you can see it, that means your Composer installation is complete. Let’s move to the next one.
Make sure that your htppd.conf includes httpd-vhosts.conf
Now let’s make sure that your htppd.conf also includes httpd-vhosts.conf. This is beneficial if you want to make a pretty URL just like this one:
Instead of writing up localhost/mylaravel, it would be “nicer” to have that pretty URL, right?
Anyway, let’s go on.
Go to C:\wamp\bin\apache\Apache2.4.4\conf and then open up httpd.conf.
After that, search for httpd-vhosts.conf and make sure that there is no ‘#’ (pound sign) in front of it. Save. After that restart Wamp just to be safe.
Now let’s begin the fun part: installing Laravel.
Install Laravel in specified folder
You usually want to install your Laravel in your www folder. (Obviously!)
So open up your command prompt, and then change directory to your WWW folder inside your wamp. For me it will be: C:\wamp\www
To change directory, just type cd c:\wamp\www
Basically you are changing folder to your www folder.
And then, you can install Laravel. Just use this in your command prompt:
composer create-project laravel/laravel your-project-name –prefer-dist
And then hit enter.
Just wait a while until it is finished downloading and installing.
Enable Laravel installer
If you want to use Laravel Installer, you have to run this command in your command prompt first:
composer global require "laravel/installer"
Wait until… everything finished.
Create Virtual Host
Now let’s create your pretty URL. You have to go to C:\wamp\bin\apache\Apache2.4.4\conf\extra and then open up httpd-vhosts.conf.
After that, you just need to paste the following and change your laravel folder to appropriate ones.
<VirtualHost *:80>
DocumentRoot “c:/wamp/www/mylaravel/public”
ServerName laravel.dev
</VirtualHost>
In my case, I used mylaravel for my laravel installation. You have to change it to something else. For server name, you can change it to whatever you want. In my case, I am using laravel.dev. (You don’t want to use google.com because if you do, you won’t be able to open up Google).
Obviously, you have to save and then restart your WAMP again.
Update Windows Hosts file
After you have changed your virtual host, you need to change your host file.
Go to C:\Windows\System32\drivers\etc and copy hosts and paste it on your Desktop. And click on the host file you have pasted on your Desktop. Open that up using Notepad.
Put this in that host file:
127.0.0.1 laravel.dev
Change laravel.dev into what you already decided in your virtual host file. For me, mine will be laravel.dev.
Copy the one that you modified just now and put it back into your C:\Windows\System32\drivers\etc folder.
You’re done!
Modified from this source: http://copygrammer.com/how-to-install-laravel-on-windows/ (my blog)
Installing Laravel framework on window via Laravel installer:
make sure you have composer on your computer.
download the Laravel installer using Composer by typing following code in the command prompt:
composer global require "laravel/installer=~1.1"
go to folder:
C:\Users\ {User Name} \AppData\Roaming\Composer\vendor
copy the vendor folder and paste it into the folder (Destination folder) where you want to install Laravel project; for example, in folder D:\Test\Laravel.
after pasting, your folder structure look like this:
D:\Test\Laravel\vendor
pressing down on Shift key and Right click on the folder vendor in your destination folder (D:\Test\Laravel\vendor), and choose "open command window here".
enter the command below:
laravel new your_project_destination
after the command runs, you will see laravel folder in your_project_destination
You can install laravel using Homestead box.
There are a few steps you need to follow.
Make sure that you have windows virtualization turned ON in your BIOS. This will save you a few hours if you are installing it for the first time.
You will also need to install Vagrant and Virtual Box before starting the installation of Homestead.
The main advantages of using Homestead is that it provides a Linux virtual machine where you can easily install packages. It does comes with a lot of packages installed.
http://deepdivetuts.com/installing-laravel-5-4-on-windows-machine-using-homestead
If you have not installed composer on your system get from here.
You will get this if you have composer on your system installed
Installing Laravel
Step 1: Installing Laravel globally.
Open cmd in Windows and enter this command.
composer global require "laravel/installer"
This will download the latest version.
Check by entering the below command.
Step 2: Creating a new Laravel Project
Run the below command in cmd, blog is the name of my new project.
laravel new projectname
That's it. Now you have your new project folder in the directory you have saved.

Resources