How to install KnpSnappyBundle in Symfony 2.8? - symfony

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"

Related

phpunit composer install dependicies via symlink

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.

PHPUnit composer installation on WAMP not working

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

How to install PHPExcel in symfony2.5 using netbeans

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/"}
},

Symfony 2 - How to determine the namespace and Bundle name for autoload.php & Appkernel.php

I'm very new to symfony2 and I cannot find this info:
To register a bundle located in my vendor dir, how to determine the namespace and Bundle name for autoload.php & Appkernel.php?
For example, I have downloaded Luiggio's PHPExcel Bundle. I have place it in vendorDir/ExcelBundle/
Where content is:
namespace Liuggio\ExcelBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class LiuggioExcelBundle extends Bundle
{
}
What lines should I put in Appkernel and namespace.php?
This and this does not work:
new Liuggio\ExcelBundle\LiuggioExcelBundle()
//'Liuggio\\ExcelBundle' => array($vendorDir. '/PHPExcel'),
I cannot use composer or github repo at all, too many proxies and restrictions where I am.
You shouldn't place bundles in your vendor directory manually. Let Composer do this for you. Not only does Composer know where vendor libraries / bundles should be located, it also adds them to your autoload files and performs some other automated tasks.
To tell Composer which libraries are required, you should add them to your composer.json:
"require" : {
(...)
"liuggio/ExcelBundle": "~2.0"
},
Next, using the command line, run the composer update command:
$ php composer.phar update
(if you don't have a file composer.phar in your project directory, but you have Composer installed globally instead, use the following:)
$ composer update
This will tell Composer to download the required dependencies, update the autoload script, etc, all automatically. When it's finished, you're ready to go.
If you can't use Composer on your server, then run it locally before you upload your files (although I strongly recommend moving to a server that does allow you to use Composer).
The line you're trying to add to AppKernel.php is correct, however it only works after running Composer (or you'd indeed have to download the files and update the autoloader manually, but I'd strongly recommend against that).
Edit
If you really can't use Composer, do the following:
Place the files of ExcelBundle in the following directory:
vendor/liuggio/ExcelBundle/Liuggio/ExcelBundle
Your line in AppKernel.php was already correct.
Add this line to autoload_namespaces.php:
'Liuggio\\ExcelBundle' => array($vendorDir . '/liuggio/ExcelBundle'),
Last but not least, complain to your system administrator that he's making your work impossible with his stupid security measures.
new Liuggio\ExcelBundle\LiuggioExcelBundle(),
in AppKernel should be working fine.
This is the namespace of the LuiggioExcelBundle class + the class name. Look how your bundles are loaded, its the same.
What's your error?
You say vendorDir/ExcelBundle/ but its vendor/ExcelBundle right?
And what do you mean by namespace.php? :o
https://github.com/liuggio/ExcelBundle ==> there readme is rly easy to understand, it should help you.
For your "proxies and restriction", composer is a powerful tool, I can help you to use it. Download this soft, the free version is enough http://www.frozenway.com/ (if you cant read french, the 1st input in the header is to translate the website, English is Anglais) With this, you wont have any ports restriction.

update to silverstripe 3.1 using composer

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

Resources