I am following a Lynda.com Tutorial and can't get PHPUnit to work.
Here is what I did:
Project folder: C:\wamp\www\stats
In this folder I have a composer.json file:
{
"require": {
},
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload": {
"psr-0": {
"stats": ""
}
}
}
I ran the composer command:
>composer update
It created a new folder C:\wamp\www\stats\vendor containing many subfolders, even /Symfony...??
Then I opened cmd.exe and wanted to run phpunit:
>cd C:\wamp\www\stats\
>phpunit
But it doesn't work. Error message:
Command "phpunit" not found
Can anyone help?
As described in documentation:
For a system-wide installation via Composer, you can run:
composer global require "phpunit/phpunit=5.0.*"
I recommend to not use version as of last stable is 5.2
Note that you should use version ^4.8 for php < 5.6
Also you need to add composer folder (C:\Users\<username>\AppData\Roaming\Composer\vendor\bin) to your path enviroment variable
Related
I can't figure out how to register a local directory as a composer package. I found lots of information about registering a local folder that is either a git repository or a composer package or even a zip hosted somewhere.
However I want to register a folder on my local machine, residing in the same repository as my wordpress installation (using wordplate) that is neither a git repository nor a composer package as it doesn't contain any composer.json.
What I try at the moment is to register it like this under repositories:
{
"type": "package",
"package": {
"name": "local/contact-form-7-mailchimp-extension",
"type": "wordpress-plugin",
"version": "dev-master",
"source": {
"type": "path",
"url": "resources/plugins/contact-form-7-mailchimp-extension",
"reference": "master"
}
}
}
Add "local/contact-form-7-mailchimp-extension": "*" under "require",
add "local/contact-form-7-mailchimp-extension" in "public/plugins/{$name}" under "extras" > "installer-paths".
Running composer install however doesn't install it and gives no information at all. Don't even know if it found the url or not..
Is it even possible to install a local directory like that?
You can use the path repository to install packages from a different path into your project.
However I want to register a folder on my local machine, residing in the same repository as my wordpress installation (using wordplate) that is neither a git repository nor a composer package as it doesn't contain any composer.json.
For this to work, your plugin inside the folder will need a composer.json, though. This is necessary for composer to recognize this folder as a package in the first place. Fortunately, it can be as simple as this:
{
"name": "local/contact-form-7-mailchimp-extension",
"description": "My Contact Form-extension using mailchimp",
"type": "wordpress-plugin",
"version": "dev-master"
}
Assuming the plugin is in the directory resources/plugins/contact-form-7-mailchimp-extension, you can now register this path as a repository path, meaning composer will look inside this folder for a composer.json and when your wordpress-project requires the provided package it will (by default) be symlinked into vendor.
The wordpress project's composer.json then needs these entries (the options for the repository are the defaults and can be left out, this is just to show how to disable symlinking, should you need that):
{
...,
"repositories": [
{
"type": "path",
"url":"resources/plugins/contact-form-7-mailchimp-extension",
"options": {
"symlink": true
}
}
],
"require": {
"local/contact-form-7-mailchimp-extension": "dev-master",
...
}
}
When composer installs the package, it should tell you where it installed it from, i.e. you should find the path from the repository in there.
I just need to install a bundle which help me to generate PDF files, but I don't know how to start to install, I don't understand the documentation, the KnpSnappyBundle's documentation says to install with composer to make:
{
"require": {
"knplabs/knp-snappy-bundle": "~1.4"
}
}
but I don't know where put such code. Nevertheless I am open to other bundle in which I can create PDF files, and please explain me step by step how to install it, I am a beginner in Symfony.
From a command line in your Symfony project folder you can run:
composer require knplabs/knp-snappy-bundle "~1.4"
And that will install the bundle for you.
I have done like below after adding it to composer.json under require
"require": {
"knplabs/knp-snappy-bundle": "dev-master"
}
After adding above run "composer update"
I am currently installing phpunit on a per project basis.
This works extremely well, however, the install takes time because I install the directories from cache each time. Is there a way to symlink the directories to one install, or some kind of clever trick I can use to make it do that.
If I do a path repository like this, with phpunit cloned and composer installed on my disk:
"require-dev": {
"phpunit/phpunit": "dev-master"
},
"repositories": [
{
"type": "path",
"url": "../phpunit",
"options": {
"symlink": true
}
}
],
This installs only links the phpunit/phpunit directory, and not the rest of the dependencies like:
"phpunit/php-code-coverage": "^5.2",
"phpunit/php-file-iterator": "^1.4",
"phpunit/php-text-template": "^1.2",etc
Composer can install packages globally and then you can refer to the files via it's path, or put the appropriate directory into your PATH variable (in ~/.composer/vendor/bin). Another, often more popular method is to download the phpunit.phar file, and use that to run PHPunit. This also has the advantage of being a single file that can also be committed to a project - though you will want to occasionally update it to the latest version (at least within the major version, 5.7+ or 6.1+). The .Phar file can also be installed globally on the server, in the same way that composer is suggested to.
I am facing problem with PHPExcel installation in symfony2.5.
I have downloaded PHPExcel directory from GitHub and I dont know the configuration steps.
as I am beginner I would need complete steps to understand the complete installation process,
Please help me regarding this,
Thanks in advance.
You can add it to your composer.json or require it with composer (php composer.phar require "phpoffice/phpexcel:1.8.0) like most other php packages which will then add it to the class loader meaning you can just use it like \PHPExcel_....
The available packages for it are on packagist.
If you are wanting to use the classes from a version that you have downloaded you can add them to your src directory and they will be autoloaded there through the default autoload setting.
"autoload": {
"psr-0": { "": "src/"}
},
Is it possible to update my project to the beta release of Silverstripe 3.1 using composer?
I have composer installed as well as a composer.json file in the root of my Silverstripe project. Here is my composer.json file:
{
"name": "silverstripe/installer",
"description": "The SilverStripe Framework Installer",
"require": {
"php": ">=5.3.2",
"silverstripe/cms": "3.0.*#stable",
"silverstripe/framework": "3.0.*#stable",
"silverstripe-themes/simple": "*"
},
"require-dev": {
"silverstripe/compass": "*",
"silverstripe/docsviewer": "*"
},
"minimum-stability": "dev"
}
When I run
composer update /Path/To/My/Site
Composer tells me that it cannot find the composer.json file even though it is there.
Am I running the wrong command?
Thanks.
You'll need to remove the "composer.lock" file (if existing), replace "3.0.*#stable" with "3.1.x-dev", and call "composer update". That'll get you the latest 3.1 branch.
Its not possible to upgrade to 3.1.0-beta1 this way, because I've mucked up the composer.json dependencies in the tag. You'll need to create a new project for that, based on the composer.lock file committed to this tag:
composer create-project silverstripe/installer test 3.1.0-beta1