These are chat archives for ppi/framework

16th
Dec 2015
Paul Dragoonis
@dragoonis
Dec 16 2015 00:00 UTC
We can do OS detection here, and stop people on Windows from trying symlink ;)
Yassine
@hubroot
Dec 16 2015 00:00 UTC
I downloaded git for windows
ok
Paul Dragoonis
@dragoonis
Dec 16 2015 00:01 UTC
That’s fine - but your command should now work if you update composer.json :)
and run composer install
There is an open bug report for your issue :) ppi/skeletonapp#43 - I will make this high priority fix for the next release
Yassine
@hubroot
Dec 16 2015 00:03 UTC
cool, now it works, by changing “symlink-relative" to “relative”as you mentioned, magic haha
Paul Dragoonis
@dragoonis
Dec 16 2015 00:04 UTC

Yea, only “symlink” works with Linux :) This bug will be fixed quickly.

With successful composer install, you should now have your FrameworkRequirements.php file

Yassine
@hubroot
Dec 16 2015 00:05 UTC
that's true, there's new files in there, I also see init.php which I guess was missing too before
now the party starts
Paul Dragoonis
@dragoonis
Dec 16 2015 00:06 UTC
Woo!
Yassine
@hubroot
Dec 16 2015 00:06 UTC
Thanks :)
Paul Dragoonis
@dragoonis
Dec 16 2015 15:05 UTC
Integrating PPI2.1 into wordpress today - got the integration working - just trying to work out why it’s not loading any modules :D
In wordpress, to get services from the DiC, you just do
$yourService = ppi(‘your.service’);
Simple
Yassine
@hubroot
Dec 16 2015 15:11 UTC
@dragoonis so Wordpres could interact with PPI ?
How did you make the integration ? (in a nutshell =! )
Paul Dragoonis
@dragoonis
Dec 16 2015 15:11 UTC
Yes
Similar code to what’s inside public/index.php
Yassine
@hubroot
Dec 16 2015 15:11 UTC
That's cool, PPI as WP plugin ?
Paul Dragoonis
@dragoonis
Dec 16 2015 15:11 UTC
Nope, you register from wordpress’ index.php, boot up ppi app
Yassine
@hubroot
Dec 16 2015 15:12 UTC
yes
hmm
Paul Dragoonis
@dragoonis
Dec 16 2015 15:12 UTC
$loader = require_once __DIR__.'/../dashboard/app/init.php';
$ppiApp = new PPI\Framework\App([
    'environment' => 'dev',
    'debug' => true,
    'rootDir' => __DIR__ . '/../dashboard/app'
]);
$ppiApp->loadConfig($ppiApp->getEnvironment() . '/app.php');
$ppiApp->boot();
$container = $ppiApp->getServiceManager();
ppi($container);

function ppi($id)
{
    static $container;

    if ($id instanceof ContainerInterface) {
        $container = $id;
        return;
    }

    return $container->get($id);
}
I have ppi dashboard app, with DoctrineORM, and wish to use my services inside of Wordpress
Yassine
@hubroot
Dec 16 2015 15:14 UTC
who is going to access the services built in PPI ? like WP plugins ?
Paul Dragoonis
@dragoonis
Dec 16 2015 15:14 UTC
Yes. I have WP plugin and customising some existing WP plugins to talk to dashboard DB instead of WP DB
$propertyService = ppi(‘property.service’);
$property = $propertyService->getById($wp_post->id);
Yassine
@hubroot
Dec 16 2015 15:15 UTC
ahh
tricky
to define services from the module main, should return a compatible array using ->getServices(), like stated in http://docs.ppi.io/latest/book/services.html ?
Paul Dragoonis
@dragoonis
Dec 16 2015 15:20 UTC
Yes, you can use callback function factory, or factory class, like this;
    public function getServiceConfig()
    {
        return ['factories' => [
            'property.images.service' => PropertyImagesFactory::class,
            'property.branch.service' => PropertyBranchesFactory::class,
        ]];
    }
Yassine
@hubroot
Dec 16 2015 15:22 UTC
wonderful, makes sense
Paul Dragoonis
@dragoonis
Dec 16 2015 15:27 UTC
That’s the migration fully working :D Time to fill WP with PPI, Symfony, Zend code and make it awesome
Yassine
@hubroot
Dec 16 2015 15:30 UTC
that's a great idea, I think it turns the field wider of what's possible in WP actually
Paul Dragoonis
@dragoonis
Dec 16 2015 15:30 UTC
Yes, I’m now using DoctrineORM inside WP, with PPI :D
:clap:
Yassine
@hubroot
Dec 16 2015 15:31 UTC
haha
nice :)
I've been trying to do something yesterday, I'm going to do it later because there's priority tasks
I made 2 modules routes the same, but only is chosen when the route is performed, I was thinking like defining a container view
with sections on it, like section 1 and section 2
Paul Dragoonis
@dragoonis
Dec 16 2015 15:34 UTC
Which router are you using on your PPI modules? You can choose from Symfony, FastRoute, Aura
Yassine
@hubroot
Dec 16 2015 15:34 UTC
symfony for now
then any module routes matching the request, the right controllers push content in the desired layout section
Paul Dragoonis
@dragoonis
Dec 16 2015 15:35 UTC
:+1:
Yassine
@hubroot
Dec 16 2015 15:36 UTC
when all module controllers are done, a filled up layout template is compiled then
Yassine
@hubroot
Dec 16 2015 15:54 UTC
I think my test service class is not loading !
Paul Dragoonis
@dragoonis
Dec 16 2015 15:59 UTC
gist your Module.php
and your app/config/base/dev.php
when I declare 'say.service' as a closure that returns a new instance of Test Service Class, it works
Paul Dragoonis
@dragoonis
Dec 16 2015 16:16 UTC
an invalid factory was registered for this instance type.
This is an example of my factory class - https://gist.github.com/dragoonis/67133a2fe14c4e9010fb
Paul Dragoonis
@dragoonis
Dec 16 2015 16:22 UTC
@jachine you need a SayFactory class, in your module: ./src/Factory/SayFactory.php
an in module.php
use Database\Factory\SayFactory;
// ...
    public function getServiceConfig()
    {
        return ['factories' => [
           'say.service' => SayFactory::class
        ]];
    }
Yassine
@hubroot
Dec 16 2015 16:24 UTC
@dragoonis this really helps, I'm implementing it now
Paul Dragoonis
@dragoonis
Dec 16 2015 16:24 UTC
Yassine
@hubroot
Dec 16 2015 16:25 UTC
This is kind, thanks :sparkles:
Yassine
@hubroot
Dec 16 2015 16:37 UTC

This works

'say.service' => function(){
               return SayServiceFactory::class;
           }

while this

'say.service' => SayServiceFactory::class

throw the same exception

Paul Dragoonis
@dragoonis
Dec 16 2015 16:40 UTC
@jachine you could just do.
'say.service' => function(){
    return new SayService();
}
Yassine
@hubroot
Dec 16 2015 18:59 UTC
@dragoonis from \ppi\skeleton-app\vendor\zendframework\zend-servicemanager\src\ServiceManager.php
inside ->createFromFactory()
I print get_declared_classes() and I see the Factory class is actually not declared, that's why it didn't work
Yassine
@hubroot
Dec 16 2015 19:04 UTC
test
Paul Dragoonis
@dragoonis
Dec 16 2015 19:06 UTC
@jachine hello! You need to register your module for autoloading. You can do PSR-4 in your composer.json if you wish, as one technique