I am quite buzzed with the whole Homestead stuff and how it correlates with an IDE. Let's say I have my PhpStorm installed in ~/Developer/PhpStorm The Homestead is in ~/Developer/Homestead. This is how my YAML file in Homestead looks like:
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Developer/Homestead/workspace
to: /home/vagrant/Code
sites:
- map: helloworld.app
to: /home/vagrant/Code/Laravel/public
variables:
- key: APP_ENV
value: local
So, you see that I have a workspace folder in the Homestead directory.
I also have another directory: ~/Developer/workspace/PHP where I am planning to store my projects, instead of in the Homestead folder.
I installed the Laravel plugin in PhpStorm. And, in order for the Laravel plugin to work in PhpStorm, this generated file is needed. My questions are:
Where exactly should I put the _ide_helper.php file so that PhpStorm works properly with Laravel? Should I paste it in each project or just once somewhere?
Do I have to write a different app name in the YAML sites: map field for every project that I want to be launching atm?
How do I create a new Laravel type project. As when I go for creating a new project in PhpStorm, there are types of which I can choose - should I also have Laravel listed there, because I do not? Because now, when I create a new PHP project - it's completely empty. And I suppose a Laravel project should have some architecture and generated files.
I beg of a simple explanation of all this Laravel + Homestead stuff and Vagrant and how to control my projects, because I am getting very frustrated and I have to start working with these technologies on my Bachelor project soon.
You shouldn't need to put the _ide_helper.php file anywhere manually, it is automatically generated by the Artisan command. For each new project, include the IDE helper in that project's composer.json file:
"require-dev": {
"barryvdh/laravel-ide-helper": "1.*"
}
Add the service provider to the providers array in the config.php file of your Laravel project:
'Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider'
Then use Artisan to generate the _ide_helper.php file for the project (run this command from the terminal in the root of your Laravel project directory):
php artisan ide-helper:generate
This is all paraphrased from the instructions on the IDE Helper GitHub page. I would recommend following those instructions to also set up your composer.json file to auto-generate a new _ide_helper.php whenever composer updates.
Yes. For each individual Laravel project, you'll need to update your sites mapping in the YAML file. For my projects, I use this scheme (note that you are mapping to the location relative to your Vagrant box):
sites:
- map: local.project.example.com
to: /home/vagrant/Projects/project/public
Then in your Homestead directory, run:
vagrant provision
You will also need to update your hosts file to point to the Vagrant box.
sudo nano /etc/hosts
Add the line:
127.0.0.1 local.project.example.com
Now you should be able to access this Laravel project by hitting: local.project.example.com:8000 in your web browser.
Assuming you followed the Laravel installation instructions, the easiest way is to use the Laravel command in the terminal. To create a new Laravel project called "blog", navigate to ~/Developer/workspace/PHP and run the command:
laravel new blog
I hope the above answers get you started down the right path. The most important thing is to carefully read the Laravel documentation as it covers everything I just did but in much greater detail.
thanks Mike Andersen, you have put me on correct way, but your solution number 1 don't work for me (using Laravel 5).
You have to run "composer update" after making changes to composer.json file. But, when i have doed, i got this error:
barryvdh/laravel-ide-helper v1.2.1 requires phpdocumentor/reflection-docblock dev-master#6d705c1a0f9e2a6d73d2e9ec0e538b9dfaf4315f -> no matching package found.
I have got another solution:
remove line about "barryvdh/laravel-ide-helper" from require array on composer.json file.
run the next line: composer require barryvdh/laravel-ide-helper
Then you can follow the steps proposed by Mike Andersen:
Add the service provider to the providers array in the config.php file of your Laravel project:
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider
Then use Artisan to generate the _ide_helper.php file for the project (run this command from the terminal in the root of your Laravel project directory):
php artisan ide-helper:generate
Open your project on phpStorm and go to: File|Synchronize.
And you will got your laravel project updated with the last version of barryvdh/laravel-ide-helper extension
(More info: https://github.com/barryvdh/laravel-ide-helper)
Related
I've seen answers for this question, but I'm still really confused, because answers say I need to be in my Laravel's project folder, which I thought I had created.
I'm trying to run the command php
php artisan horizon:install
This is the second step in the Laravel installation guide found here: https://laravel.com/docs/7.x/horizon#installation
My directory structure looks like this in my documents folder in Mac OS:
I've tried running the command in the RetimeWeb, vendor, bin, laravel and horizon folders. What am I doing wrong here? Where is an artisan folder supposed to be?
Laravel Horizon is dashboard for managing queues (jobs) in Laravel that supposed to be installed on top of Laravel project.
Based on your directory structure you installed Horizon from composer alone. Now you are trying to run command "php artisan horizon:install" but artisan is a tool from Laravel.
"horizon:install" supposed to copy all assets, configs etc to Laravel project - but again, you do not have any so there is not even where to copy it.
To summary.
Install Laravel.
Install Laravel Horizon.
Do cd until you're in the root folder of your project and run the command again. artisan file is in the root folder of a laravel project
I used to map only one folder to my projects root folder as recommended in Laravel 5.6.
Now, I mapped each folder to each separate project as recommended in Laravel 6.x.
Now if I login into my VS with vagrant ssh and try laravel new myproject I get
The provided cwd "/home/www/myproject" does not exist
If I create the folder beforehand, than I get
Application already exists
If I install as root, then Laravel gets installed, but I can't find my project on my PC. I see it on my VS, buts it not on my hard-drive.
This is the config in my Homestead.yaml:
- map: ~/www/homestead/myproject # Path on my laptop
to: /home/www/myproject #Path of VM
I find /home/www/myproject which I created on my VS, but ~/www/homestead/myproject does not exist on my PC.
I did not have these issues when I was only mapping one folder. How can I fix this and create a new Laravel project?
I solved this by installing Laravel command globally with composer on my PC. To do so, I had to install zip first:
sudo apt-get install php7.2-zip
Then I could install it globally
composer global require laravel/installer
Which displayed
Changed current directory to /home/adam/.config/composer
and I had to add this to my ~/.profile:
PATH="$HOME/.config/composer/vendor/bin:$PATH"
I reloaded profile in command with source ~/.profile and then I finally could install Laravel from my PC instead from the VM.
How to setup existing laravel 5 project and there database in Ubuntu 14.04 using xampp?
Some of things you need to consider for new setup. If you have setup git repo then
You can just pull from git If not copy/paste all folders except vendor, node_modules.
Use composer install to make vendor folder
Use npm install to make node_modules folder if you already using
Use php artisan migrate to make database structure
Use php artisan db:seed if you set any seeding to fill tables data
Use php artisan key:generate to make security.
Create/Update .env file to make work configuration from environment
Now you have to point your domain with root folder of laravel you created here.
I'm learning Laravel and they say in order to create a new laravel site you have to make your folders like this:
--webshop
--root
--laravel (contains the laravel files)
--assets (contains the css,fonts,img,js from the public folder of laravel)
--.htaccess
--favicon.ico
--index.php
--robots.txt
--web.config
So as you can see I cut the containers of public folder inside Laravel and paste them in the root directory. So now I want to start the project and make it live on the localhost using Artisan commands but I don't know in which folder I have to make it live... For example root directory or laravel directory inside of root or something else... So can u please help me!
No, that's wrong. install laravel by composer like this:
composer require --prefer-dist laravel/laravel mysite
from inside mysite start project by run the artisan command php artisan serve and enter in the browser the url 127.0.0.1:8000
more information here
Have you checked Wamp or Xampp if you're on Mac/Linux, it's a PHP local server with phpmyadmin if you want to test out with a local database. Also have you created your project with composer create-project --prefer-dist laravel/laravel nameofyourproject? It installs all the basic folders you need to start using laravel right away, you can then copy those files on Wampp/Lampp and use localhost.
Refer to the documentation here:https://laravel.com/docs/5.4
If you have composer installed, use:composer global require "laravel/installer"
Now, to create a new project simply run : laravel new ProjectName.
No need to create a directory structure on your own.
I have installed Symfony2 on a iis 7 server with PHP 5.3.21 and everything works ok ( the php, the symphony demo page ).
I try to create my own helloWorld, as the tutorial says :
php app/console generate:bundle
I go Start->Run->CMD and put that line of code and it gives me back this :
could not open input file : app/console
and before anyone asks i am in the project directory when i perform this command
I put the PHP directory to the System PATH but the problem persists.
Update: I ended up getting on a screen sharing program with #reza and discovered he had accidentally set his PATH variable to D:\php\wamp\bin\php\php5.3.10\php.exe rather than D:\php\wamp\bin\php\php5.3.10. Fixing this solved the problem.
Check this: I can't create bundle in symfony2
For newer versions of Symfony (2.4.x or newer) use this method on windows to resolve the problem:
Go to project directory e.g. d:/xampp/symfony2-project/ and open composer.json and place this under requires array "symfony/console": "2.4.*#dev". And save the file.
Open command-line and cd to project's directory.
Use this command to let download and install the dependencies: php path/to/composer.phar install. Remember you should be in your project's directory and path/to/composer.phar is the actual path to your composer.phar file.
Now you are all done, just use php bin/console generate:bundle --namespace=Test/PrintBundle --format=yml to test bundle system works.
If you are creating Symfony 2.5 project using command prompt then console file is not storing the app folder but it storing in the bin folder so you need to use bin folder instead of app folder (CODE is : php bin/console generate:bundle).