How use phly-expressive-oauth2clientauthentication module for zend-expressive - php

Hy,
I would like to use this module (https://github.com/phly/phly-expressive-oauth2clientauthentication)in my expressive application.
I read this documentation https://phly.github.io/phly-expressive-oauth2clientauthentication
here is what I did :
in my config/autoload folder i add a oauth2clientauthentication.global.php with this array :
'oauth2clientauthentication' => [
'routes' => [
'production' => '/(:provider)(/oauth2callback)',
],
],
in my pipeline.php file i add
use Phly\Expressive\OAuth2ClientAuthentication\OAuth2CallbackMiddleware;
$app->pipe('/auth', OAuth2CallbackMiddleware::class);
in my ConfigProvider.php file i add a route with this config (I use slim router with https://github.com/acelaya/expressive-slim-router:
[
'name' => 'admin',
'path' => '/admin',
'allowed_methods' => ['GET'],
'middleware' => [
SessionMiddleware::class,
AuthenticationMiddleware::class,
Action\AdminAction::class,
],
When i tried this url : 'http://blog/admin', i get my unauthenticated page with github button. But when i click on the button the url is : 'http://blog/auth/github?redirect=http://blog/admin' and get an error :
Unable to resolve service "Zend\Expressive\Delegate\NotFoundDelegate"
I do not understand where is the problem, anyone have an idea to solve this?

It looks like you upgraded your Expressive installation without going through the migration guide.
Check your config/autoload/dependencies.global.php. It should contain something like this:
use Zend\Expressive\Container\NotFoundDelegateFactory;
use Zend\Expressive\Delegate\NotFoundDelegate;
return [
'dependencies' => [
'aliases' => [
'Zend\Expressive\Delegate\DefaultDelegate' => NotFoundDelegate::class,
],
'factories' => [
NotFoundDelegate::class => NotFoundDelegateFactory::class,
],
],
];

Related

Declaring filter in application in Yii framework

In Yii doc, it is said that
Besides controllers, you can also declare filters in a module or application.
But, how to implement that in application, programmatically?
You can attach behavior for application in its config.
For example attaching ContentNegotiator in your frontend\config\main.php:
return [
'as contentNegotiator' => [
'class' => \yii\filters\ContentNegotiator::class,
'formats' => [
'application/json' => \yii\web\Response::FORMAT_JSON,
'application/xml' => \yii\web\Response::FORMAT_XML,
],
'languages' => [
'en-US',
'de',
],
],
// ... other configuration ...
];

Laminas - Unable to render template "xxxxxxx" resolver could not resolve to a file

This project has been ported over manually from Zend Frame work 2 to Laminas. The issue here is that the module.config.php has been set up in the same way as other modules that are working. However I am encountering this error. I have checked the usually culprits such as files spelling or missing, no other modules are using the same route name. Is there another part of Laminas that would affect the view manager?
The modul.config.php setup is below.
'''
namespace ProjectTaskDocument;
use Laminas\Router\Http\Segment;
return [
'router' => [
'routes' => [
'project-task-document' => [
'type' => Segment::class,
'options' => [
'route' => '/task-document[/:action][/:id]',
'constraints' => [
'action' => 'index|add|download|view-all|delete'
],
'defaults' => [
'controller' => Controller\ProjectTaskDocumentController::class,
'action' => 'index'
]
]
]
]
],
'view_manager' => [
'template_path_stack' => [
'ProjectTaskDocument' => __DIR__ . '/../view'
],
]
];
'''
The module folder structure
Realised my mistake, during my port process another module was using the same Key identifier for the view_manager->template_path_stack. I feel pretty damn dumb for missing this.

Laravel GraphiQL "documentation explorer" says "no schema available"

I'm using this Laravel graphQL implementation : https://github.com/rebing/graphql-laravel, which uses this graphiQL implementation : https://github.com/graphql/graphiql
I'm trying to explore my graphQL schema using graphiQL through https://my_IP/graphiql route, but it just says NO SCHEMA AVAILABLE as follow:
However, it should display documentation like here : https://graphql.org/swapi-graphql
I have schema declaration in config/graphql.php as follow:
'schemas' => [
'default' => [
'query' => [
'users' => \myPath\UsersQuery::class,
'subscribers' => \myPath\SubscribersQuery::class,
...
],
'mutation' => [
...
],
'middleware' => [],
'method' => ['get', 'post'],
],
],
Did I miss some configuration to allow the documentation exploration ?

Yii DbMessageSource App* Error

I am currently building a second system with yii2. It will use some tables from a Yii1 database for translation. The Yii1 project was originally translated using files but this has now been moved to the db. All the translations of the Yii1 system use one of three categories app,flash,email of which the vast majority use app.
In the Yii2 project I have the following in the web.php config file.
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'cdb',
'sourceMessageTable' => 'translation_source',
'messageTable' => 'translation',
'forceTranslation'=>true,
],
],
],
All of the translations on the system that use app are not translated, however, all other categories are. If I change the above code to
'i18n' => [
'translations' => [
'app*' => [
Then I get an error for other categories but not app and the app strings are translated as expected. The error I get is
Unable to locate message source for category 'flash'.
If however I change my config to the following, this works for all translations.
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'cdb',
'sourceMessageTable' => 'translation_source',
'messageTable' => 'translation',
'forceTranslation' => true,
],
'app*' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'cdb',
'sourceMessageTable'=>'translation_source',
'messageTable' => 'translation',
'forceTranslation' => true,
],
],
],
It just seems odd that I am having to include effectively the same code block twice. Can anyone tell me how I can achieve this in one array or is this the expected behaviour?
** Update **
I do see some mention of * in the docs Docs. I also see some mention of this in the Forum

Controller mapping causing error in yii2 console application

Module section config
'user' => [
'class' => 'dektrium\user\Module',
'modelMap' => [
'User' => 'app\models\DL\User',
'registrationForm' => 'app\models\DL\registrationForm',
],
'controllerMap' => [
/*'registration' => 'app\controllers\user\RegistrationController',
'admin' => 'app\controllers\user\AdminController'*/
],
'layout' => '#app/views/layouts/container',
'defaultRoute' => 'profile',
'admins' => ['admin'],
'enableFlashMessages' => false,
'params' => [
'menuItems' => [
'label' => 'Users',
'url' => ['/user/admin']
]
]
],
Yii console application (./yii) showing me error
'Calling unknown method:
app\controllers\user\AdminController::getHelpSummary()'
If I uncomment the controllerMap section, I can't understand why it autoloads in console app if my AdminController extends web controller not console.
This is commands from user module.
Do you really need the user module in console?
Yii2 console and web applications have separated configuration files by default. If you changed this default and use the same config for both of them, you must take care about consistency.
You can check the list of loaded configs in ./yii.
You need to specify a valid defaultRoute for the console application.
With 'defaultRoute' => 'profile', ./yiimay try to load a Controller which requires the user module.
Try adding it in the console configuration.

Categories