Zend2 install ZendOauth module with composer - php

I'm totally new to zend2 and would like to install the zendframework/zendoauth module.
I added the module to composer.json and installed it properly with "composer install"
Contents of my composer.json
{
"name": "my_project_name",
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
}
],
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": ">2.2.0rc1",
"doctrine/doctrine-module": "*",
"doctrine/doctrine-orm-module": "*",
"zendframework/zendoauth": "2.0.*",
}
}
This downloaded the module into vendor/zendframework/zendoauth.
I edited config/application.config and added 'ZendOauth'.
Contents of my config/application.config.php
<?php
return array(
// This should be an array of module namespaces used in the application.
'modules' => array(
'Application',
'ZendOAuth'
),
...
Now when i try to access my website i get an error:
Fatal error:
Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException'
with message 'Module (ZendOAuth) could not be initialized.'
My question is: Is there anything i missed?!
Thanks in advance!

ZendOAuth isn't a module, it's a library, which is why you're getting an error message when you add it to the list of modules. You just use the classes it supplies in your own application.
Unfortunately, there doesn't appear to be any documentation for it at the moment, but to get an idea of usage, maybe take a look at the unit tests https://github.com/zendframework/ZendOAuth/tree/master/tests/ZendOAuth

Related

Class not found using custom composer package

I have created a custom comoposer package and I want to use it on my project with this composer.json:
{
"name": "papillon/test",
"type": "library",
"version": "dev-master",
"require": {
"php": "^7.1.11"
},
"autoload": {
"psr-4": {
"Papillon\\Fountaine\\Eau\\": "src/Papillon/Fountaine/Eau/"
}
}
}
I compress it in zip. In the main project, I add a folder called repo, where I add de composer package zip. Then, I modify the composer.json of the main project like this:
{
"repositories": [
{
"type": "artifact",
"url": "var/main/repo"
}
],
"require": {
"papillon/test": "dev-master"
}
}
I execute composer update and the pakage is added to vendor folder; all seems to be going well... but if I want to test the package from the main project with this script:
<?php
require (__DIR__ . '/vendor/autoload.php');
use Papillon\Fountaine\Eau\FlowerClass;
echo FlowerClass::bloom();
It returns: PHP Fatal error: Uncaught Error: Class 'Papillon\Fountaine\Eau\FlowerClass' not found in .../test_package.php:6
Stack trace:
#0 {main}
thrown in .../test_package.php on line 6
I think that the package may not be recognized by the main project; maybe the package was improperly installed in the main project?
Debugging autoload can be very useful to catch errors. Take care with the route paths, the autoload tryed to find the classes files in a path with a lowercase folder when in the package composer.json the route was definded with that folder uppercase.

Can't require local package with composer

I'm currently working on a Composer package and now I want to test how it would integrate in my current application without pushing it to a remote.
So I stumbled upon this blog post which explains how to do that. However, that didn't work. I'm getting the message
Your requirements could not be resolved to an installable set of packages.
Problem 1 - The requested package tzfrs/x-bundle could not be found in any version, there may be a typo in the package name.
My directory structure looks like this
dev
Project
composer.json
Package
composer.json
The composer.json of my package looks like this
{
"name": "tzfrs/x-bundle",
"license": "proprietary",
"require": {
"php": "^7.0",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~5.5"
},
"autoload": {
"psr-4": { "tzfrs\\XBundle\\": "" },
"exclude-from-classmap": [
"/Tests/"
]
}
}
And the one of my project looks like this (I'm leaving the symfony stuff and other packages/stuff out)
{
"repositories": [
{
"type": "git",
"url": "../Package",
}
],
"minimum-stability" : "beta",
"require": {
"tzfrs/x-bundle": "*"
}
}
So when doing composer update tzfrs/x-bundle I should get my new project right? However, I'm getting the message I posted above. What am I doing wrong here?
I already did git init in my package folder and also comitted all my changes. So I have a repo which is not empty already.

Mediawiki extensions, will not read my i18n file

As far as i'm aware, the only steps required in order to create a internationalized extension is to create a i18n file like the following:
//SemanticHighcharts.i18n.php
$messages = array();
$messages['en'] = array(
'semantichighcharts-desc' => 'A SMW result format displaying data with the help of highcharts
);
and then reference this file with the global variable wgExtensionMessageFiles
//SemanticHighcharts.php
global $wgExtensionMessagesFiles, $wgExtensionCredits;
$wgExtensionCredits['semantic'][] = array(
'path' => __FILE__,
'name' => 'SemanticHighcharts',
'version' => '0.0.1',
'url' => 'https://www.mediawiki.org/wiki/Extension:SemanticHighcharts',
'descriptionmsg' => 'semantichighcharts-desc'
);
//i18n
$wgExtensionMessagesFiles['SemanticHighcharts'] = dirname(__FILE__) . '/SemanticHighcharts.i18n.php';
This should cause the descriptionmsg in wgExtensionCredits to be internationalized when displayed on Special:Version.
However this is not the case... In fact, no message key from the i18n file is being read!
How can i debug this issue? I've tried to debug callstack when doing a wfMessage() call without any great success.
Any help is appreciated. I'm running the latest version of mediawiki from git. And all extensions have been installed with composer.
//composer.json
{
"require": {
"php": ">=5.3.2",
"mediawiki/side-bar-menu": "dev-master",
"mediawiki/semantic-highcharts": "dev-master",
"mediawiki/semantic-result-formats": "dev-master"
},
"suggest": {
"ext-fileinfo": "*",
"ext-mbstring": "*",
"ext-wikidiff2": "*",
"ext-apc": "*"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/netbrain/SemanticHighcharts"
}
]
}
Typical, after struggling with this issue for quite some time. Right after posting this question I tried to remove all other extensions from composer.json, and did a composer update. Which magically fixed my issue.
I'm suspecting that there might be a conflicting extension or maybe it was just something wrong with the composer autoloading mechanism.
Ill try to look into it further.
It seems that composer was the culprit, after re-adding the extensions previously removed, it still worked. So i can only guess that there is some quirk in composers dependency management.

Laravel 4 - Extend application controller from a package

Background
I know what I'm trying to do sounds a bit wrong but I do have my reasons.
Basically I have a central core app that's a default laravel app with a few tweaks and boilerplate code, I have then developed a series of packages that can be used to extend the app through composer. These packages are not meant to function without the core framework so a dependency upon it is fully expected.
What I want to do
What I would like to do is have a BaseController in my core app and have the various controllers in my package extend this BaseController to provide universal functionality throughout the various module packages.
I was expecting to be able to place the base controller in app/controllers/BaseController.php
and then extend it from my package using:
class PackageController extends \BaseController{}
Unfortunately when I do this it still looks within the package (currently workbenched) for the controller and I get the error:
include(/var/www/l4core.dev/workbench/myvendor/mypackage/src/controllers/BaseController.php):
failed to open stream: No such file or directory
Can anyone tell me what I'm doing wrong here. I am looking for a solution which allows me to easily move my packages between vendor dir and workbench for development. Any help greatly appreciated
Update
The previously mentioned error message appears to have been due to an include in my packages /vendor/composer/classloader.php - I have now deleted the vendor directory and done a fresh composer install. This has not solved the problem but it has at least shifted it as I now get the following error message:
Class 'BaseController' not found
My Packages composer.json
{
"name": "modules/sesame",
"description": "",
"authors": [
{
"name": "any",
"email": ""
}
],
"require": {
"php": ">=5.4.0",
"illuminate/support": "4.0.x",
"zizaco/confide": "dev-master",
"zizaco/entrust": "dev-master",
"conarwelsh/mustache-l4": "dev-master"
},
"autoload": {
"classmap": [
"src/controllers",
"src/models",
"src/migrations",
"src/seeds"
],
"psr-0": {
"Modules\\Sesame": "src/"
}
},
"minimum-stability": "dev"
}
Be sure to execute:
php artisan dump-autoload
And verify that your class BaseController is in /vendor/composer/autoload_classmap.php.
OR like the OP stated, removing the vendor directory and running composer install again could sometimes solve the problem.

How do I get PEAR.php with Composer?

I installed pear/archive_tar to work with Phing, which I installed with Composer. However, I received this error:
BUILD FAILED
exception 'BuildException' with message 'Error reading project file [wrapped: You must have installed the PEAR Archive_Tar class in order to use TarTask.]' in vendor/phing/phing/classes/phing/parser/ProjectConfigurator.php:197
I added the PEAR repository to Composer and updated, but it still did not work.
The second half of this question branched off here.
I set my composer.json to this, and it was fixed:
{
"repositories": [
{
"type": "pear",
"url": "http://pear.php.net"
}
],
"require": {
"phing/phing" : "2.6.1",
"pear-pear.php.net/pear": "*"
}
}
Native Composer libraries such as this do not work, because Composer does not add the pear/archive_tar package to the autoloader:
{
"require": {
"phing/phing" : "2.6.1",
"rsky/pear-core-min" : "dev-master",
"pear/archive_tar" : "1.3.11"
}
}

Categories