install Slim3 beta with composer? - php

how can I install Slim3 beta with composer?
I tried --dev with no luck
The official docs say nothing and composer search revealed nothing.

Run the following command from from commandline.
$ composer require slim/slim:~3.0#dev
Another option is to create a composer.json with the following content.
{
"require": {
"slim/slim": "~3.0#dev"
}
}
After creating the file in the same folder run
$ composer install

Related

PHPUnit version does not match version in Composer

I'm trying to update my phpunit version, however it doesn't seem to be working with the regular composer install.
My composer.json file is as follows:
{
"require": {
...
},
"require-dev": {
"phpunit/phpunit": "4.*",
"phpunit/php-invoker": "^1.1",
"phpunit/dbunit": "^2.0"
}
}
And running both composer install and update as php composer.phar install and php composer.phar update (I don't have composer installed globally which might be the issue?) I get
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
When I check to see the phpunit version, I get
$ phpunit --version
PHPUnit 3.7.28 by Sebastian Bergmann.
My PHP version is 5.6 which does seem to rule out the solution from this very similar issue.
My best guess is that there is a global version of phpunit installed and overriding my local one. But I haven't been able to find any guidance as to how to fix this without making too many changes to the rest of the global environment.
The command by itself phpunit will search in your shell's path for a PHPUnit executable. A composer install will place it into the composer bin dir, which is vendor/bin by default. You can execute the script directly with ./vendor/bin/phpunit, or allow composer to execute it for you, resolving the proper path for your project with composer exec phpunit

How to install PHRETS 2.0?

What are all the step by step process to install phrets in ubuntu?
I tried the following, but then unable to run phrets
First I got installed composer.
Then I ran composer require troydavisson/phrets
Now I have two files composer.json and composer.lock, and a folder named "vendor"
Inside vendor folder, I can see autoload.php file and some other folders
Now I tried the sample code from phrets git
But then am getting the following error,
PHP Fatal error: Class 'Monolog\Logger' not found in /var/www/testing/newphrets.php on line 7
Please advice what am missing here. Am planning to switch my project from old version to phrets 2.0.
Thanks
According to Troy's PHRETS 2.0 Logging video on YouTube and looking at PHRETS' composer.json, you can see that you need to do one of two things. Either,
(a) Add monolog to your project's composer.json,
{
"require": {
"troydavisson/phrets": "2.*",
"monolog/monolog": ">=1.10"
}
}
and run composer update in your project's root directory.
or,
(b) Since monolog is in PHRETS' composer.json file but in the require-dev section, run composer install --dev or composer update --dev to indicate you're currently in development and would like to use the development libraries.

Install extension using composer in yii2.0

How can i install yii/jui in yii2.0 using composer. I have tried
php composer.phar require --prefer-dist yiisoft/yii2-jui "*"
and added to composer.json
"yiisoft/yii2-jui": "*"
but it did not succeed. Can anyone help me how to use composer to install extension in yii 2.0 .
When i am running $ php composer.phar require yiisoft/yii2-jui "*" in cmd it is just opening the composer.phar file, nothing else happening.
Thank you in advance.
Please check in composer.json file for yiisoft/yii2-jui under "require". You might be see like that
"require": {
"yiisoft/yii2-jui": "2.0.*#dev"
},
If you didn't see, please add this and run composer.phar install or composer install. If already install, use composer.phar update or composer update
I have been updated my answer. Please take a look. The packagist is Here.
Hopefully, you already installed Yii-2 with composer. I have been installed (basic application template) step by step.
Step 1.
Before installation, Yii official website said that, we require to install this package before installation Yii 2. This step will follow after composer installation.
sudo composer global require "fxp/composer-asset-plugin:1.0.0-beta4"
Please take a look attach file.
This time is yii-2 installation with composer.
sudo composer create-project yiisoft/yii2-app-basic basic 2.0.1
Please take a second and third attach image.
After that, please go to your project folder. Then, open your_project_folder/composer.json. I have been used vi to open compser.json. You can use whatever your prefer. Please take a look again for attach image.
The next step is final step for complete install for your package. After adding this
"yiisoft/yii2-jui": "*"
under require keyword, please save your composer.json file. Then run this command.
sudo composer update
Please take a look attach image again.
Please check your folder on your_project_folder/vender/yiisoft/yii2-jui
That's all. Hope this help for your stack. Btw, if you want to use composer command, please used the following command. This will help to call composer from everywhere.
sudo mv composer.phar /usr/local/bin/composer
I use Windows 10, To install php composer.phar requires --prefer-dist yiisoft/yii2-jui.

Class not found in ProviderRepository.php error with composer install

I'm currently in the process of trying to include this package in my Laravel app: https://github.com/tappleby/laravel-auth-token
I included "tappleby/laravel-auth-token": "0.3.*" in composer.json, like this:
"require": {
"laravel/framework": "4.2.*",
"intervention/image": "dev-master",
"laracasts/flash": "~1.0",
"laracasts/validation": "1.1.*",
"tappleby/laravel-auth-token": "0.3.*"
}
And I added 'Tappleby\AuthToken\AuthTokenServiceProvider' and 'AuthToken'=>'Tappleby\Support\Facades\AuthToken','AuthTokenNotAuthorizedException' =>'Tappleby\AuthToken\Exceptions\NotAuthorizedException' to app/config/app.php.
Afterwards I ran composer install. This is the way I always added packages, but now I get an error every time: [RuntimeException]
Error Output: PHP Fatal error: Class 'Tappleby\AuthToken\AuthTokenServiceProvider' not found in /var/www/example.com/htdocs/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157
Goto bootstrap/cache folder and delete config.php
Then run
composer dump-autoload
As Marcin said you shouldn't use
composer install
but
composer update
Second thing remove all the lines added to app/config/app.php
First run composer update after that put those lines in app/config/app.php
Then run php artisan config:publish tappleby/laravel-auth-token in your command line
It should publish your configuration and now you should be able to use the relevant classes
Order is mandatory, run composer update then add the service provider and aliases to app.php
php artisan optimize:clear
composer install
If that don't work
remove composer.lock
remove vendor folder
composer install
You should run:
composer update
and not
composer install
When adding new dependency you should always use composer update to update your project and not composer install
Your config file may be cached. Remove all files from bootstrap/cache/*
after that run
composer install --optimize-autoloader --no-dev
php artisan config:cache

Install PHPUNIT with Composer

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

Categories