I have installed library called chosen js via composer. Now I have it in my composer.json file
"require": {
"harvesthq/chosen": "^1.8"
},
How can i use it in my project? Where do I need to require it ?
Install any packages in the Laravel
(1)first way: via composer
open project path in terminal and fire this command
composer require harvesthq/chosen
(2)Second way: add package name in composer.json file
"require": {
"harvesthq/chosen": "^1.8"
},
and fire this command
composer update
When I use composer to install packages in my project I am only able to do so if I update my json file manually.
For example, if I run the following command in Git-Bash in my project directory (which contains my composer.phar and composer.json file):
php composer.phar require php-di/slim-bridge
It returns the following error:
[Invalid Argument Exception]
Could not find package
php-di\slim-bridge at any version for your minimum-stability (stable).
Check the package spelling or your minimum stability.
However, if i were to just update my json file to the following (example I've provided contains multiple packages I am using in my project):
{
"require": {
"slim/slim": "^3.0",
"slim/twig-view": "^2.1",
"illuminate/database": "^5.2",
"respect/validation": "^1.0",
"slim/csrf": "^0.6",
"slim/flash": "^0.1",
"phpmailer/phpmailer": "^5.2",
"php-di/slim-bridge":"^1.0"
},
"autoload":{
"psr-4": {
"App\\": "app"
}
}
}
... And I run the command: $ php.composer.phar update
Everything installs to project correctly.
What is going on that I am not able to install packages using the require method thus making me resort to manually updating my json file each time?
Since I am using windows, I used the windows installer for composer rather than install through command line and I got this working correctly. Much much easier now since I don't have to update my JSON files manually.
recently I've started one project and want to use elasticsearch. But when I want to install guzzle for PHP via composer, I get folowing error. I have no idea what is this error.
My composer required packages are:
"require":{
"yiisoft/yii":"1.1.14",
"2amigos/yiiwheels":"1.0.3",
"clevertech/yii-booster": "4.0.1",
"drmabuse/yii-bootstrap-3-module": "dev-master",
"guzzle/guzzle": "3.9.0",
"elasticsearch/elasticsearch": "1.2.2"
},
my PHP Version 5.4.7
my composer.json file
I had no problem installing all the packages from your requirements in one go.
If the problem persists, try to delete the vendor folder and the composer.lock file and run composer update again.
I installed a new symfony 2.4 project and I installed also phpDocumentor using composer.phar folowing these steps:
1- Adding:
"require-dev": {
"phpdocumentor/phpdocumentor": "2.*"
} to My composer.json
2- Executing : php composer.phar update
After installation terminated I can see phpdocumentor Folder in /vendor so I guess installation is terminated with success.
Now I want to know how to use phpDocumentor on symfony (generate a documentation for my code source).
I work on Ubuntu web server.
Thank you and sorry for my bad english.
STEP 1. Add a dependency to phpdocumentor/phpdocumentor to the require-dev section of your project's composer.json configuration file, and update your application.
{
"require-dev": {
"phpdocumentor/phpdocumentor": "2.*"
}
}
STEP 2. Run composer update command inside your project
STEP 3. Go to vendor\phpdocumentor\phpdocumentor\bin directory of your project from CMD and then run following command to generate document of AppBundle/Controller folder code. This will generate document of your AppBundle/Controller folder at \phpdocumentor\phpdocumentor\bin\doc destination.
Command:- php phpdoc run -d ../../../../src/AppBundle/Controller/ -t doc/
I have project on Symfony 2 and i would like use PHPUNIT on Windows 7.
On githut phpunit is:
Composer
Simply add a dependency on phpunit/phpunit to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json file that just defines a development-time dependency on PHPUnit 3.7:
{
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}
For a system-wide installation via Composer, you can run:
composer global require 'phpunit/phpunit=3.7.*'
Make sure you have ~/.composer/vendor/bin/ in your path.
First i use system-wide installation but i dont know when this installed.
Next i add to my composer.json require-dev.
This installed phpunit in C:/wamp/www/myproject/vendor/symfony. Next i try commands:
composer install --dev
And i can't use phpunit. In cmd.exe i enter "phpunit" and i have error:
'phpunit' is not recognized as an internal or external command operable program or batch file
How can i use phpunit? I have Windows 7, Wamp server and php 5.4.12.
When you install PHP-Unit in windows via composer, the global installation will create files in
C:\Users\YOUR_USERNAME\AppData\Roaming\Composer
To execute phpunit easily via command line you need to add path of phpunit.bat file in windows Environment Variables. For this:
Right click My Computer
Go to Properties -> Advance system settings and
Click Environment variables from the Advance tab.
Now add C:\Users\YOUR_USERNAME\AppData\Roaming\Composer\vendor\bin to the windows PATH.
You can now run the phpunit from command. Note that you may need to restart your command prompt for the changes to take effect.
The bin file of packages are put in the configured bin directory. By default, this is vendor/bin and when you use the symfony standard edition, this is the bin folder.
To execute this bin file, run ./bin/phpunit (or ./vendor/bin/phpunit when not using the Symfony Standard Edition)
Windows users have to put this in double quotes: "bin/phpunit" (or "vendor/bin/phpunit")
composer require --dev phpunit/phpunit ^7
The above example assumes, composer is already on your $PATH variable.
You composer.json should look similar to;
{
"name": "vendor_name/package_name",
"description": "This project is for practicing writing php unit tests",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
{
"name": "Umair Anwar",
"email": "umair.anwar#gmail.com"
}
],
"autoload": {
"classmap": [
"src/"
]
},
"require-dev": {
"phpunit/phpunit": "^7",
"phpunit/dbunit": "^4.0"
}
}
Easiest way to install phpunit via composer is to run from project root.
$ composer require phpunit/phpunit
What this would do is, it will create a phpunit folder inside vendor/bin
and you can run unit tests like this..
$ ./vendor/bin/phpunit
Too simple operation on Windows with composer and works for me following way:
Install composer
https://getcomposer.org/doc/00-intro.md#installation-windows Go to
your symphony folder e.g C:\wamp64\www\symfony\UserManagement where is
composer.json and run this command.
Should be register with global to not have issue $phpunit bash: phpunit: command not found
//old version is 5.7 new 6.4 or put newest version.
composer global require --dev phpunit/phpunit ^5.7
I remember futzing around with the composer dependency stuff for phpunit and never could get it to work.
Instead, from your git bash shell:
mkdir ~/bin
cd ~/bin
curl https://phar.phpunit.de/phpunit.phar > phpunit
chmod +x phpunit
exit out of bash and then start a new bash session.
And you should be good to go. You can echo $PATH to verify you have a path to ~/bin but one seems to added by default.
https://phar.phpunit.de/phpunit.phar
I also came across the same issue and find out the solution by following steps
To run PHPUnit in Windows 7 under WAMP installation
Composer Install
{
"require-dev": {
"phpunit/phpunit": "3.7.*"
}
}
Simply Set Environment Variable
The php unit will be install in a vendor dir in vendor/bin
Path : C:\wamp\www\myproject\vendor\bin;
Open a new Command Prompt
C:\Users\guny >phpunit --version
PHPUnit 3.7.30 by Sebastain Bergmann