Has anybody ever used Symfony in conjunction with payone(payone.de)?
I got the SDK and it has the folders js, locale and php.
My problem: I don't really know how to include/use them in my project(inexperienced in Symfony) because I don't know where I should place it and how to include it. I read about the auto loader but since the SDK doesn't follow the standards needed(concerning folder structure) I guess it's not the way to go.
You can autoload all classes with the psr-0 too if the classes are following the PEAR-style non-namespaced convention.
To manage the vendor download via composer, you can define a package in your composer.json directly.
{
"repositories": [
{
"type": "package",
"package": {
"name": "payone/php-sdk",
"version": "1.0.0",
"dist": {
"url": "http://github.com/PAYONE/PHP-SDK/archive/master.zip",
"type": "zip"
},
"autoload": {
"psr-0": { "Payone_": "php/" }
}
}
}
],
"require": {
"payone/php-sdk": "1.0.*"
}
}
Note: This repository type has a few limitations and should be avoided whenever possible:
Composer will not update the package unless you change the version field.
Related
I'm trying to upgrade Twig 1.13.2-DEV to 3.x but don't know how to do that as on their
Website not clearly mentioned and they suggest to ask question on StackOverflow :)
I used Twig only with Symfony framework not with Custom PHP website, Right now I can see two directories in server
Twig
Twig-extensions
And inside /Twig/lib/Twig/Environment.php it display me the version
const VERSION = '1.13.2-DEV';
Can someone have idea how to upgrade Twig?
My project is not using composer.json but inside Twig folder I have this compsoer.json
"name": "twig/twig",
"type": "library",
"description": "Twig, the flexible, fast, and secure template language for PHP",
"keywords": ["templating"],
"homepage": "http://twig.sensiolabs.org",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien#symfony.com"
},
{
"name": "Armin Ronacher",
"email": "armin.ronacher#active-4.com"
}
],
"require": {
"php": ">=5.2.4"
},
"autoload": {
"psr-0" : {
"Twig_" : "lib/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
}
}
I have a project that compiles that I want to test using xUnit. However although the project lets me add the references and builds, as soon as I add a using statement to the test class I get the red squiggly lines and the error "type or namespace could not be found."
Even though the xproj of the project I want to test has been added to references, and the namespaces do exist. It has to be something I have done, but I can't see what. Using earlier versions of .net, I have added references to test projects hundreds of times without an issue.
So what is different in the way .NET works, and why does it not recognize my namespaces in my referenced assemblies?
Update: I have removed xUnit and got MSTest working, but I have the same issue. So this may be a feature of the way I have dotnetcore set up, and the references in my json files more than anything else.
This structure works for me in .NET Core 1.0:
global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}
src/MyLibrary/project.json
{
"dependencies": { },
"frameworks": {
"netstandard1.3": {
"dependencies": {
"NETStandard.Library": "1.6.0"
}
}
},
"version": "1.0.0"
}
test/MyLibrary.Test/project.json
{
"dependencies": {
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"MyLibrary": {
"target": "project",
"version": "1.0.0"
},
"xunit": "2.1.0"
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dnxcore50",
"portable-net45+win8"
]
}
},
"testRunner": "xunit",
"version": "1.0.0"
}
Using this directory and project structure, both the Visual Studio Test Explorer and dotnet test work and can run xUnit tests.
I'm using a grunt plugin called bower-concat. This plugin takes all your bower_component packages and concatenates them into a single file. It does this by looking at each component's bower.json file's "main" attribute. I'd like to modify my font-awesome's bower.json "main" attribute from
{
"name": "font-awesome",
"description": "Font Awesome",
...,
"main": [
"less/font-awesome.less",
"scss/font-awesome.scss"
]
...
}
to this, which allows my grunt-bower-concat plugin to work.
{
"name": "font-awesome",
"description": "Font Awesome",
...,
"main": [
"./css/font-awesome.css",
"./fonts/*"
]
...
}
By following this post here (https://roots.io/using-bootstrap-with-bower-how-to-override-bower-packages/), I thought I'd be able to override this attribute like so in my app's bower.json file to achieve the desired result upon bower install ...
{
"name": "MyApp"
"dependencies": {
"font-awesome": "~4.4.0"
},
"overrides": {
"font-awesome": {
"main": [
"./css/font-awesome.css",
"./fonts/*"
]
}
}
}
Unfortunately, this doesn't appear to override font-awesome's "main" attribute. Can anyone point out what I'm missing?
I'm trying to use the payone PHP-SDK from http://github.com/PAYONE/PHP-SDK/archive/master.zip
I included it in my composer.json like this:
"require": {
"payone/php-sdk": "1.0.*"
},
"repositories": [
{
"type": "package",
"package": {
"name": "payone/php-sdk",
"version": "1.0.0",
"dist": {
"url": "http://github.com/PAYONE/PHP-SDK/archive/master.zip",
"type": "zip"
},
"autoload": {
"psr-0": { "Payone_": "php/" }
}
}
}
]
My question: How do I use it in my controller?
Please note the PayOne SDK uses PEAR style classnames ( i.e. Vendor_Folder_Classname ) and not the PSR-0 convention with namespaces. pear style autoloading is compatible with composer's psr-0 autoloading.
Make sure you prefix the classnames with \ or add a use statement on top of your controller class.
See igor's answer here.
To instantiate a new builder object use something like:
class MyController
{
public function myAction()
{
$conig = new \PayOne_Config(array(/* settings */));
$builder = new \PayOne_Builder($config);
// now use the builder
}
The PayOne_Autoload and PayOne_Bootstrap classes are only needed for setting up autoloading which is in your case handlded by composer.
I am creating a CpanelBundle which will integrate the Cpanel xmlapi into Symfony.
I will use the class provided by CpanelInc here: https://github.com/CpanelInc/xmlapi-php.
I want to make this bundle usable across projects and also open source.
The Symfony documentation says you should not put third party libraries into your bundles. The Cpanel class also don't have a namespace and its not on composer.
I could and should put the Cpanel class in vendor folder but how can I add it to autoload and to my bundle composer.json so when I release my bundle the user will also get it?
Hello you can load this file using composer. Please see composer autoload documentation
Your composer.json can looks like:
{
"name": "my/bundle",
"autoload": {
"psr-0": {"": "src"}
},
"require": {
"php": ">=5.3.2",
"symfony/framework-bundle": ">=2.1,<2.3-dev",
"CpanelInc/xmlapi-php": "*"
},
"repositories": [
{
"type": "package",
"package": {
"name": "CpanelInc/xmlapi-php",
"version": "master-dev",
"dist": {
"url": "http://github.com/CpanelInc/xmlapi-php/zipball/master",
"type": "zip"
},
"source": {
"url": "git://github.com/CpanelInc/xmlapi-php.git",
"type": "git",
"reference": "master"
},
"autoload": {
"files" : ['xmlapi.php']
}
}
}
]
}
Will be even better when you just create composer.json and add it for CpanelInc/xmlapi-php and do PR :)