These are chat archives for ppi/framework

1st
Dec 2015
Martin Janeček
@wodCZ
Dec 01 2015 10:02
@dragoonis i'm here already :)
Paul Dragoonis
@dragoonis
Dec 01 2015 10:02
@wodCZ greetings
that does look like smarty.
Martin Janeček
@wodCZ
Dec 01 2015 10:03
probably, as neon looks like yaml :)
Paul Dragoonis
@dragoonis
Dec 01 2015 10:04
that’s mad!
Martin Janeček
@wodCZ
Dec 01 2015 10:04
(neon is default config format in nette)
Paul Dragoonis
@dragoonis
Dec 01 2015 10:04
intersting. PPI uses .yml or .php - using Symfony - http://talks.ppi.io/20151017-fwdays/#/43
Paul Dragoonis
@dragoonis
Dec 01 2015 10:12
yeah, you’re right!
Paul Dragoonis
@dragoonis
Dec 01 2015 10:34
I gotta rename to Latte
Martin Janeček
@wodCZ
Dec 01 2015 10:59
great, fell free to ask me anything, will try to help as much as I can
Paul Dragoonis
@dragoonis
Dec 01 2015 10:59
@wodCZ i’ve begun making a PoC, to invoke up a .latte file with the LatteEngine
I’ll ping you very soon.
$latte->setTempDirectory('/path/to/tempdir’);
Okay to set this to the app’s cache_dir config setting ?
Martin Janeček
@wodCZ
Dec 01 2015 11:00
I think yes, it is where compiled templates will be stored
so it is cache
Paul Dragoonis
@dragoonis
Dec 01 2015 11:00
perfect then, was expecting setCacheDir or setCompileDir, or something, for that
Martin Janeček
@wodCZ
Dec 01 2015 11:01
looks like this then: http://i.imgur.com/rFk1O8N.png
one .php file and one .lock file (not sure why lock)
Paul Dragoonis
@dragoonis
Dec 01 2015 11:02
cool !
Paul Dragoonis
@dragoonis
Dec 01 2015 11:13
@wodCZ getting closer! How do you tell Latte where to find the templates?
Martin Janeček
@wodCZ
Dec 01 2015 11:14
@dragoonis nette bridge takes care of that, latte itself only handles rendering/compiling here
Paul Dragoonis
@dragoonis
Dec 01 2015 11:16
interesting? a bridge? show me :)
Martin Janeček
@wodCZ
Dec 01 2015 11:17
moment please, reading code if i'm not misleading
Paul Dragoonis
@dragoonis
Dec 01 2015 11:17
@wodCZ okay, i seen Engine->setLoader(), which might be close?
Martin Janeček
@wodCZ
Dec 01 2015 11:17
@dragoonis here is the bridge
@dragoonis default file loader only loads defined file
Paul Dragoonis
@dragoonis
Dec 01 2015 11:21
@wodCZ i actually have the full path to the tempalte file, coz symfony tells me
return $this->render('Application:index/subdir:index.html.latte', compact('items'));
becomes modules/Application/resources/views/index/subdir/index.html.latte
I just need to tell Latte “this is the DIR and this is the FILE” or “this is the FILE"
Martin Janeček
@wodCZ
Dec 01 2015 11:23
I understand, I'll try to get anyone smarter than me in nette chat and then look into code :)
Paul Dragoonis
@dragoonis
Dec 01 2015 11:24
cool
Martin Janeček
@wodCZ
Dec 01 2015 11:28
looks like latte just takes file and parses it, probably it is place where custom ILoader implementation should come
which will have configurable DIR and will be able to get FILE then
Paul Dragoonis
@dragoonis
Dec 01 2015 11:32
Martin Janeček
@wodCZ
Dec 01 2015 11:32
@dragoonis yes
it will then get $name passed to $engine->render/renderToString($name, $params) in $loader->getContent($name);
Paul Dragoonis
@dragoonis
Dec 01 2015 11:34
Yup, I got this now.
coding.
Martin Janeček
@wodCZ
Dec 01 2015 11:34
awesome
Paul Dragoonis
@dragoonis
Dec 01 2015 12:07
@wodCZ
    public function getServiceConfig()
    {
        return ['factories' => [
            'templating.engine.latte' => LatteWrapperFactory::class,
            'latte.engine' => LatteEngineFactory::class,
            'latte.loader' => LatteLoaderFactory::class
        ]];
    }
Martin Janeček
@wodCZ
Dec 01 2015 12:09
@dragoonis looks good while I don't know what it is :D
Paul Dragoonis
@dragoonis
Dec 01 2015 12:29
@wodCZ super close now!
get the champagne ready!
Paul Dragoonis
@dragoonis
Dec 01 2015 12:31
:clap:
Tadaa!!!
$items = ['hello', 'latte', 'items'];
return $this->render('Application:index/subdir:index.html.latte', compact('items'));
<ul n:if="$items">
{foreach $items as $item}
    <li id="item-{$iterator->counter}">{$item|capitalize}</li>
{/foreach}
</ul>
dannym87
@dannym87
Dec 01 2015 12:32
nice!
Paul Dragoonis
@dragoonis
Dec 01 2015 12:32
Output:

<ul>
    <li id="item-1">Hello</li>
    <li id="item-2">Latte</li>
    <li id="item-3">Items</li>
</ul>
Martin Janeček
@wodCZ
Dec 01 2015 12:34
@dragoonis, you are real master. Latte implementation in 1,5 hours.. :D
very nice job
Paul Dragoonis
@dragoonis
Dec 01 2015 12:36
I spent 30 minutes moving furniture with family B-)
Martin Janeček
@wodCZ
Dec 01 2015 12:37
:D :clap:
Paul Dragoonis
@dragoonis
Dec 01 2015 12:38
I’m now adding Latte to the Create Module Wizard
Martin Janeček
@wodCZ
Dec 01 2015 12:39
3... 2.... 1.... done? :D
Paul Dragoonis
@dragoonis
Dec 01 2015 12:39
Yeah - stand by!
Martin Janeček
@wodCZ
Dec 01 2015 12:43
@dragoonis if I want to start new project with ppi, this will show me basics?
(busy at work at moment, but now I have to try ppi, so preparing it when I get home :) )
Paul Dragoonis
@dragoonis
Dec 01 2015 12:44
@wodCZ cool - skeleton app - master branch - composer install - vagrant up -> done :D
http://docs.ppi.io/latest/setup/install.html
Martin Janeček
@wodCZ
Dec 01 2015 12:45
thank you!
Paul Dragoonis
@dragoonis
Dec 01 2015 12:46
oh Plates support isn’t in the Create Module Wizard either - so adding Plates and Latte there :)
Roman Tsiupa
@dracony
Dec 01 2015 13:16
well no we know that Latte is way better written for extensibility than Plates
=)
Paul Dragoonis
@dragoonis
Dec 01 2015 13:22
agreed!
Roman Tsiupa
@dracony
Dec 01 2015 13:24
well pixie yu can just configure those module folders with a config =P
Paul Dragoonis
@dragoonis
Dec 01 2015 13:24
Well let’s go then! :P
Pixie time!
Link me to pixie docs, or example of integrating Pixie
all here
example in examples folder
here is the config you need:
Paul Dragoonis
@dragoonis
Dec 01 2015 13:25
I specify the template path on a per-render basis, not per boot/config (like Plates)
Roman Tsiupa
@dracony
Dec 01 2015 13:26
$config = [
   'resolver' => [
        'locator' => [
            'type' => 'prefix',
            'locators' => [

                'module1' => [
                    'directory' => '/module/1/path/',
                ],
                'module1' => [
                    'directory' =>  '/module/2/path/',
                ]
           ]
    ]
];
ah
wait
how do you reference layouts then?
Paul Dragoonis
@dragoonis
Dec 01 2015 13:27
{{ extend ‘path’ }}
Roman Tsiupa
@dracony
Dec 01 2015 13:27
and it has to be full path?
Paul Dragoonis
@dragoonis
Dec 01 2015 13:28
Nope, symfony has shortcuts
Roman Tsiupa
@dracony
Dec 01 2015 13:28
so basically what you want is the ability to pass the absolute path
and r ender it
right?
Paul Dragoonis
@dragoonis
Dec 01 2015 13:28
yes
Roman Tsiupa
@dracony
Dec 01 2015 13:29
$slice = new \PHPixie\Slice();
$config = $slice->arrayData([
   'resolver' => [
        'locator' => [
             'directory' => '/'
       ]
   ]
]);
$template = new \PHPixie\Template($slice, $config);
bang and you are done
Paul Dragoonis
@dragoonis
Dec 01 2015 13:34
Testing plates/latte in the create module wizard, and then moving to Pixie
Paul Dragoonis
@dragoonis
Dec 01 2015 13:54
Having to clean up the module wizard code, like this:
    protected function isValidRoutingEngine($tplEngine)
    {
        return in_array($tplEngine, [
            self::ROUTING_ENGINE_SYMFONY,
            self::ROUTING_ENGINE_AURA,
            self::ROUTING_ENGINE_LARAVEL,
            self::ROUTING_ENGINE_FASTROUTE
        ]);
    }
Paul Dragoonis
@dragoonis
Dec 01 2015 14:06
damn, .plate files are giving me issues
needs to be .plates files
Jonathan Reinink
@reinink
Dec 01 2015 14:29
Hey!
Roman Tsiupa
@dracony
Dec 01 2015 14:29
you missed the plates party
Paul Dragoonis
@dragoonis
Dec 01 2015 14:29
hi @reinink - plates made its way in today - unmerged to master tho
we had champagne
Pauls-MBP:skeletonapp dragoonis$ app/console module:create PlatesTestModule
Where is the modules dir?
  [1] /Users/dragoonis/code/ppi/skeletonapp/modules
 >
Choose your templating engine [php]
  [1] php
  [2] twig
  [3] smarty
  [4] plates
  [5] latte
 > 4
Choose your routing engine [symfony]
  [1] symfony
  [2] aura
  [3] laravel
  [4] fastroute
 > 4
Created module successfully
Name: PlatesTestModule
Routing: fastroute
Templating: plates
Path: /Users/dragoonis/code/ppi/skeletonapp/modules/PlatesTestModule
This module is not enabled. Enable it in config[modules] key
Paul Dragoonis
@dragoonis
Dec 01 2015 14:35
HTML Output:
Welcome to your plates powered module: PlatesTestModule
Jonathan Reinink
@reinink
Dec 01 2015 14:35
Amazing! Sorry for the delay, my daughter just woke up. :)
I'm sorry I haven't been more helpful. Life has been nuts recently.
Paul Dragoonis
@dragoonis
Dec 01 2015 14:36
@reinink i made a symfony bridge, in PPI, for Plates - https://gist.github.com/dragoonis/65a5199c113ea9e18354
Roman Tsiupa
@dracony
Dec 01 2015 14:36
DaughterException raised
=)
Paul Dragoonis
@dragoonis
Dec 01 2015 14:36
return $this->render('PlatesTestModule:index:index.html.plates’);
Jonathan Reinink
@reinink
Dec 01 2015 14:37
@dracony Haha, yep!
So, high level, how does this work? When someone sets up this framework, they are asked which templating engine they want to use. They choose Plates, and then what, it add it's to their Composer file?
Paul Dragoonis
@dragoonis
Dec 01 2015 14:38
@reinink the wizard will tell them to run “composer require ppi/plates-module” if they’ve not got it there already
Jonathan Reinink
@reinink
Dec 01 2015 14:38
Gotcha, that makes sense
Paul Dragoonis
@dragoonis
Dec 01 2015 14:39
It will tell them to update their app’s config file, to add ‘plates’ as a valid templating engine.
Jonathan Reinink
@reinink
Dec 01 2015 14:39
So, does this also require a specific file extension?
Paul Dragoonis
@dragoonis
Dec 01 2015 14:39
lol ^
.plates, right now - but it’s built with extension changing in mind, but there’s probably some coupling in there somewhere
Will need your support to make it extra special.
Jonathan Reinink
@reinink
Dec 01 2015 14:40
cool, is it .plates or .plates.php?
Paul Dragoonis
@dragoonis
Dec 01 2015 14:40

.plates, for now, bcoz symfony PhpEngine wants .php

I aim to customise symfony so it doesn’t just look at the last dot. I also said earlier that I wanted .plates.php

Jonathan Reinink
@reinink
Dec 01 2015 14:41
Understood
So, what do you need from me? How can I help make it extra special?
Roman Tsiupa
@dracony
Dec 01 2015 14:41
a config option with the extension would be nice
=)
so then it would be possible to just have it .php
Paul Dragoonis
@dragoonis
Dec 01 2015 14:41
@dracony already in there, but i’m not 100% convinced it will work thus far.
Roman Tsiupa
@dracony
Dec 01 2015 14:42
I ment in Plates
Paul Dragoonis
@dragoonis
Dec 01 2015 14:42
so did I
PhpEngine is reserving that right now.
Roman Tsiupa
@dracony
Dec 01 2015 14:42
wo why wouldnt it work?
Jonathan Reinink
@reinink
Dec 01 2015 14:42
Yes, you can set this with Plates already.
Paul Dragoonis
@dragoonis
Dec 01 2015 14:43
I’ve done that, lemme link you
This is the guy!
and the file extension check for SF templating supports()
https://github.com/ppi/ppi-plates-module/blob/master/src/Wrapper/PlatesWrapper.php#L75
I will give it a spin now, will change it to .reinink :P
Jonathan Reinink
@reinink
Dec 01 2015 14:48
Haha, go for it.
Paul Dragoonis
@dragoonis
Dec 01 2015 14:48
$config['plates']['ext'] = 'reinink’;
HAWW
Jonathan Reinink
@reinink
Dec 01 2015 14:49
I'm not totally following how all this works. My goal with Plates was to not require a specific file extension. Technically, it could just be .php, since they are plain old PHP files after all. However, I understand that frameworks often use the extension to determine what templating engine to use.
Paul Dragoonis
@dragoonis
Dec 01 2015 14:49
return $this->render('PlatesTestModule:index:index.html.reinink’);
works :D
that was easy, took 15 seconds
My PlatesTestModule that I created earlier, I just made the config file have this
<?php
$config = array();
$config['plates']['ext'] = 'reinink';
return $config;
Jonathan Reinink
@reinink
Dec 01 2015 14:51
Amazing
Paul Dragoonis
@dragoonis
Dec 01 2015 14:52
extension changing worked first time - good job @reinink on providing that ability
Martin Janeček
@wodCZ
Dec 01 2015 14:53
@dragoonis You should not implement anything more today, or you will get drunk :D
Jonathan Reinink
@reinink
Dec 01 2015 14:56
HAHAHA
Good stuff. I don't really feel like I added any value here, but it was nice to be along for the ride. :)
Paul Dragoonis
@dragoonis
Dec 01 2015 14:56
Layouts haven’t been considered :)
they’re important
Jonathan Reinink
@reinink
Dec 01 2015 14:57
Wouldn't layouts just work, since these are defined within the templates themselves?
Paul Dragoonis
@dragoonis
Dec 01 2015 14:57
layout paths
Jonathan Reinink
@reinink
Dec 01 2015 14:58
Or do you mean there is layout support within the PPI framework?
Paul Dragoonis
@dragoonis
Dec 01 2015 14:58
yes ^
Jonathan Reinink
@reinink
Dec 01 2015 14:58
Right, how are they defined right now?
Paul Dragoonis
@dragoonis
Dec 01 2015 14:58
They’re not :) I only just managed to render single template
I just typed this:
<?php $this->layout('PlatesTestModule:index:base.html.reinink'); ?>
<p>Welcome to your plates powered module: PlatesTestModule</p>
Jonathan Reinink
@reinink
Dec 01 2015 14:59
Oh, sorry, I misunderstood. I thought you meant that template layouts are a PPI framework specific feature/configuration.
Paul Dragoonis
@dragoonis
Dec 01 2015 14:59
No they’re not - ppi just hands off control over to Plates
Jonathan Reinink
@reinink
Dec 01 2015 14:59
Okay, right
Paul Dragoonis
@dragoonis
Dec 01 2015 14:59
ppl doesn’t actually provide anything itself
Need to get inside your path resolution mechanism.
Geting inside Lette’s was easy, because there was a “Loader” class to put inside “LetteEngine"
and I put my symfony path resolvers in there.
Jonathan Reinink
@reinink
Dec 01 2015 15:00
Yeah, this could be more tricky
Paul Dragoonis
@dragoonis
Dec 01 2015 15:03
Looks like you do your resolution here, right? setName()
https://github.com/thephpleague/plates/blob/master/src/Template/Name.php#L74
Jonathan Reinink
@reinink
Dec 01 2015 15:05
Yep, exactly
(sorry, on standup)
Paul Dragoonis
@dragoonis
Dec 01 2015 15:05
ok

There’s 2 references to ‘new Name’ here - https://github.com/thephpleague/plates/blob/master/src/Engine.php#L240-L257

If I extended PlatesEngine, then I could override these 2 methods, and my own Name class, which extends your Name class. to override Name->getPath() and such.

This would allow me to inject my symfony path resolvers into the Name class.
but … I would prefer to commit directly to Plates project and make it more flexible, but it might be BC break to have NameResolver injected as a dependency instead of just “new Name()” which has crippled us here :)
Martin Janeček
@wodCZ
Dec 01 2015 15:11
@dragoonis maybe something like this would do the job without BC break?
Paul Dragoonis
@dragoonis
Dec 01 2015 15:12
@wodCZ you mean by making these functions here use getLoader() ?
Martin Janeček
@wodCZ
Dec 01 2015 15:12
@dragoonis exactly
Paul Dragoonis
@dragoonis
Dec 01 2015 15:12
That would work - will wait for @reinink to confirm.
Martin Janeček
@wodCZ
Dec 01 2015 15:13
not sure about immutability though
Paul Dragoonis
@dragoonis
Dec 01 2015 15:13
Change
$name = new Name($this, $name);
to
$name = $this->getName($this, $name);
Martin Janeček
@wodCZ
Dec 01 2015 15:16
or $this->getNameFactory()->create($this, $name); in case that Name should be always new instance
Paul Dragoonis
@dragoonis
Dec 01 2015 15:16
I need to get a Parser and Locator into the path resolution.
How would you get NameFactory into PlatesEngine class ?
Setter?
Martin Janeček
@wodCZ
Dec 01 2015 15:16
yes
Paul Dragoonis
@dragoonis
Dec 01 2015 15:16
Interesting.
I will extend PlatesEngine now, add this in, and if @reinink wants me to add it to make Plates better, then I’ll add it there and remove from PPI
thanks @wodCZ !
Martin Janeček
@wodCZ
Dec 01 2015 15:18
function getNameFactory(){
    if(!$this->nameFactory){
        $this->nameFactory = new DefaultNameFactory();
    }
    return $this->nameFactory;
}
function setNameFactory(INameFactory $nameFactory){
    $this->nameFactory = $nameFactory;
}

class DefaultNameFactory implements INameFactory {
     public function create($a, $b) { // dont know names/types of params :)
          return new Name($a, $b);
     }
}
Paul Dragoonis
@dragoonis
Dec 01 2015 15:18
Thanks sir!
I have this, so far;
namespace PPI\PlatesModule\PlatesEngine;

use League\Plates\Engine as BaseEngine;
use League\Plates\Template\Name as DefaultNameFactory;
class PlatesEngine extends BaseEngine
{
    public function setNameFactory()
    {

    }
}
Martin Janeček
@wodCZ
Dec 01 2015 15:22
@dragoonis updated snippet
Paul Dragoonis
@dragoonis
Dec 01 2015 15:22
thanks.
Martin Janeček
@wodCZ
Dec 01 2015 15:23
I owe you some help for implementing latte :)
Paul Dragoonis
@dragoonis
Dec 01 2015 15:26

@wodCZ

return new Name($a, $b);

This is PPI Name class? or Plates Name class?

I need to re-use existing Name class, but override 2 methods on it (getPath, setName())

Jonathan Reinink
@reinink
Dec 01 2015 15:45
I could see adding the ability to define your own path resolver (Name). We could add $engine->setName(). If that's set, it uses it, otherwise falls back to the Plates default.
Paul Dragoonis
@dragoonis
Dec 01 2015 15:46
@reinink that’s what I’ve already been doing, but I called it setNameFactory() instead
Jonathan Reinink
@reinink
Dec 01 2015 15:46
Right, sorry, just catching up here
Paul Dragoonis
@dragoonis
Dec 01 2015 15:46
namespace PPI\PlatesModule\PlatesEngine;

use League\Plates\Engine as BaseEngine;
use League\Plates\Template\Name as DefaultNameFactory;
use PPI\PlatesModule\PlatesEngine\Template\NameFactory;

class PlatesEngine extends BaseEngine
{

    protected $nameFactory;

    public function path($name)
    {
        $name = $this->getNameFactory()->create($this, $name);
        return $name->getPath();
    }

    public function exists($name)
    {
        $name = $this->getNameFactory()->create($this, $name);
        return $name->doesPathExist();
    }

    public function setNameFactory(PlatesNameFactory $nameFactory)
    {
        $this->nameFactory = $nameFactory;
    }

    public function getNameFactory()
    {
        if($this->nameFactory === null) {
            return new DefaultNameFactory();
        }
        return $this->nameFactory;
    }
}
Jonathan Reinink
@reinink
Dec 01 2015 15:47
However, part of the issue I see here is that Plates has a certain way of working with paths, and that's almost a feature of Plates. So, I wonder if this is going too far with it.
To me, the issue trying to be solved here is really more about the base paths, no?
What if you let Plates handle path resolving like it normally does
But, PPI simply set the default paths appropriately first, using config settings
Paul Dragoonis
@dragoonis
Dec 01 2015 15:48
I’d like that.
Jonathan Reinink
@reinink
Dec 01 2015 15:48
So, Plates has two types of paths.
The first is the default template path, that is set when you first create the engine instance. Ie: new League\Plates\Engine('/path/to/templates')
So, you could use a PPI config value here to say where the templates are.
Paul Dragoonis
@dragoonis
Dec 01 2015 15:49
Our system is configured to respond to symfony ::base.php resolving to app/views in the root.
Is this default template path? or the LAYOUT path ?
Jonathan Reinink
@reinink
Dec 01 2015 15:50
Right, so could that value simply be passed into the Engine object?
Both, they can be the same thing
let me illustrate
Paul Dragoonis
@dragoonis
Dec 01 2015 15:50
bcoz ::base.php is the global template path (commonly used for layouts)
Jonathan Reinink
@reinink
Dec 01 2015 15:50
oh, okay
Paul Dragoonis
@dragoonis
Dec 01 2015 15:50
but you can do MyModule:folder:base.php
Jonathan Reinink
@reinink
Dec 01 2015 15:51
Okay, so, some ideas
Paul Dragoonis
@dragoonis
Dec 01 2015 15:51
resolving to ./modules/MyModule/resources/views/folder/base.php
Jonathan Reinink
@reinink
Dec 01 2015 15:52
Okay, so real simple, if you wanted to just use app/views, you could use that as the default folder, which could then look like this:
app/views
    header.php
    footer.php
    home.php
Paul Dragoonis
@dragoonis
Dec 01 2015 15:52
:)
<?php $this->layout(‘home.php’); ?>
Like that ?
Jonathan Reinink
@reinink
Dec 01 2015 15:53
Yes, or even simplier <?php $this->layout('home') ?>, since you could set the extension default in Plates
but yes, basically that
well, no
crap, sorry
when you say layout, I don't really know what you mean
Paul Dragoonis
@dragoonis
Dec 01 2015 15:53
like the thing you extend ?
Jonathan Reinink
@reinink
Dec 01 2015 15:53
Right, yes, okay
exactly
or, with your template you could also do:
<?php $this->insert('header') ?>

<p>Your content.</p>

<?php $this->insert('footer') ?>
As for the modules, you could use paths for this
Rather, folders
But folders must be predefined, which is where we might have a problem
For example
$templates->addFolder('module_name', '/path/to/the/module');
And then, to use that in your templates, you could do this:
$engine->render('module_name::template_name');
Folders are implemented using two colons ::
Sort of like a namespace
Paul Dragoonis
@dragoonis
Dec 01 2015 15:57
How would I extend a layout in the same module ?
/modules/MyModule/resources/views/folder/base.php
/modules/MyModule/resources/views/folder/create.php
Jonathan Reinink
@reinink
Dec 01 2015 15:58
Something like this:
<?php $this->layout('module_name::base') ?>

<h1>Create</h1>
Basically, the folders (or namespaces) correlate to a specific path.
It's for convenience, because then you don't have to put the full path in all your templates.
Paul Dragoonis
@dragoonis
Dec 01 2015 15:59
Yea, i get that. When a user creates a Plates-powered module in PPI by default. We could hot-wire a Folder for them ?
Jonathan Reinink
@reinink
Dec 01 2015 16:00
This is also handy if template folders change or move. All the templates themselves will continue to work.
That would be great if you could hot-wire a folder for them.
You could do a 1-1 for all PPI modules to Plates folders.
Paul Dragoonis
@dragoonis
Dec 01 2015 16:01
Yes, so this could be config driven?
Jonathan Reinink
@reinink
Dec 01 2015 16:01
However, if you don't do that, then yes, you would need some type of manual path resolution.
Paul Dragoonis
@dragoonis
Dec 01 2015 16:01
PPI module config could have some paths it would self-register for you upon boot ?
Jonathan Reinink
@reinink
Dec 01 2015 16:01
I feel like it could.
So
for example
app/views, could always be set to the layouts folder.
Paul Dragoonis
@dragoonis
Dec 01 2015 16:02
Agreed.
Jonathan Reinink
@reinink
Dec 01 2015 16:02
layouts::default
or whatever
so, as long as you don't have a module call layouts, you'll be fine
Paul Dragoonis
@dragoonis
Dec 01 2015 16:02
Just like $config[‘plates’][‘ext’] - I could have.
$config[‘plates’][‘folders’][‘MyPlatesModule'] = __DIR__ '/../views/'
then when we load up PlatesEngine, I can parse config and check.
Jonathan Reinink
@reinink
Dec 01 2015 16:03
Yes, exaclty
it would be awesome if you could just automatically do that
Paul Dragoonis
@dragoonis
Dec 01 2015 16:03
:+1: We can do it no problem
Jonathan Reinink
@reinink
Dec 01 2015 16:03
I'm not sure if that's possible though
For example
If you had 5 modules, and on boot you know that they are, you could simply auto assign those paths to Plates folders
However, what exactly are modules in PPI?
Are they separate composer libraries?
Paul Dragoonis
@dragoonis
Dec 01 2015 16:04
PPI Modules === ZF2 Modules
Jonathan Reinink
@reinink
Dec 01 2015 16:04
Right, so basically a folder within the app to collect related things
Paul Dragoonis
@dragoonis
Dec 01 2015 16:04
It is ZF2, with some symfony sprinkled on top :P
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        // @todo - find out global app/views path as default engine path
        // @todo - find out pre-defined folders and assign them
        $engine = new PlatesEngine();
        return $engine;
    }
Jonathan Reinink
@reinink
Dec 01 2015 16:05
Haha, nice
Yep, that sounds like the nicest way of working with it to me
I personally don't like long paths in templates themselves
It creates a tight dependency between the templates and where they happen to be placed
Which is where folders (namespaces) came from
Paul Dragoonis
@dragoonis
Dec 01 2015 16:06
        $engine = new PlatesEngine();
        $config = $serviceLocator->get('Config');
        if(isset($config['plates']['folders'])) {
            foreach($config['plates']['folders'] as $folderName => $path) {
                $engine->addFolder($folderName, $path);
            }
        }
        return $engine;
Jonathan Reinink
@reinink
Dec 01 2015 16:06
Yep, that would totally work
Anyway, I've got to run guy. We can talk more later.
Got to get some work done! :)
Paul Dragoonis
@dragoonis
Dec 01 2015 16:09
@reinink okay I will crack on here.
Jonathan Reinink
@reinink
Dec 01 2015 16:09
Cool, and hit me up on twitter if you need something in the meantime
Paul Dragoonis
@dragoonis
Dec 01 2015 16:09
When I’ve got something to show - I’ll tweet ya to come in.
Jonathan Reinink
@reinink
Dec 01 2015 16:09
Beauty!
Peace guy
Paul Dragoonis
@dragoonis
Dec 01 2015 16:10
If you install Gitter app, you can setup notifications when your name is mentioned
peace, thanks again!
Jonathan Reinink
@reinink
Dec 01 2015 16:10
I may need to do that
this is my first gitter experience
Paul Dragoonis
@dragoonis
Dec 01 2015 16:16
$engine = new PlatesEngine();
$engine->setDirectory($serviceLocator->get('templating.locator')->getAppPath());

$config = $serviceLocator->get('Config');
if(isset($config['plates']['folders'])) {
    foreach($config['plates']['folders'] as $folderName => $path) {
        $engine->addFolder($folderName, $path);
    }
}

return $engine;
So beautiful!
Paul Dragoonis
@dragoonis
Dec 01 2015 16:28
This message was deleted
This message was deleted
This message was deleted
This message was deleted
Paul Dragoonis
@dragoonis
Dec 01 2015 16:35
It’s working. Extending base templates now.
<p>Base plates template</p>
<?=$this->section('content')?>
Jonathan Reinink
@reinink
Dec 01 2015 16:56
Nice!
Do you need anything still from me?
Paul Dragoonis
@dragoonis
Dec 01 2015 16:57
I did, which is why I pinged you, then I got it working :P
Initiating a template is still doable like this.
return $this->render('PlatesTestModule:index:index.html.reinink’);
but I believe you could do
$this->getService(‘plates.engine’)->render(
    ‘PlatesTestModule::index.html.reinink’
);
Jonathan Reinink
@reinink
Dec 01 2015 16:59
very cool!
Paul Dragoonis
@dragoonis
Dec 01 2015 16:59
As this would invoke plates.engine - parse the config Folders, and then render.
Martin Janeček
@wodCZ
Dec 01 2015 16:59
@dragoonis just run through composer create-project and in checker i got failed at app/cache/ directory must be writable while they just didn't exist (but php had rights to create them)
Paul Dragoonis
@dragoonis
Dec 01 2015 17:00
@wodCZ perhaps they need to exist in the skeleton app by default? :)
Martin Janeček
@wodCZ
Dec 01 2015 17:00
i would expect that
should I post issue? :)
Paul Dragoonis
@dragoonis
Dec 01 2015 17:01
Sure! :D Also with any other things you find.
Martin Janeček
@wodCZ
Dec 01 2015 17:18
so i contributed: ppi/skeletonapp#51 :)
Paul Dragoonis
@dragoonis
Dec 01 2015 17:19
merged
next! :)
Martin Janeček
@wodCZ
Dec 01 2015 17:19
that was fast, thanks! :)
Martin Janeček
@wodCZ
Dec 01 2015 17:38
another, this one was just wierd
maybe here before is_writable($dir) should be !?
why chmod it if it is writable?
Paul Dragoonis
@dragoonis
Dec 01 2015 17:41
There was a reason we added that, but I don’t recall it now. Can you delete lines 46 -> 50 ?
Martin Janeček
@wodCZ
Dec 01 2015 17:42
That PR just fixes impropper $mode parameter (which should start with 0 when specifying octal mode)
that actually broke that directories, so kind of hotfix
Paul Dragoonis
@dragoonis
Dec 01 2015 17:46
@wodCZ okay - merged - thanks :)
update your current repos to latest master. I merged my plates/latte work - which had ad-hoc fixes for random bits and bobs
You may be behind latest and greatest :)
Martin Janeček
@wodCZ
Dec 01 2015 17:49
also please release so sandboxapp gets that fix :)
Paul Dragoonis
@dragoonis
Dec 01 2015 17:49
you mean create Tag/Release?
Martin Janeček
@wodCZ
Dec 01 2015 17:50
not sure, "ppi/distribution-module": "~1.0" - thats in require section of sandboxapp
Paul Dragoonis
@dragoonis
Dec 01 2015 17:50
Ah, this.
Martin Janeček
@wodCZ
Dec 01 2015 17:51
probably also run composer update, as create-project runs composer install (which is still locked to older version)? :)
why did I touch that :D
Paul Dragoonis
@dragoonis
Dec 01 2015 17:53
@wodCZ there is no composer.lock in the repo :)
you can do “composer update ppi/distribution-module” from skeleton app.
Martin Janeček
@wodCZ
Dec 01 2015 17:53
oh, my bad, sorry
works great now, clean check after create-project! thank you @dragoonis :)
Paul Dragoonis
@dragoonis
Dec 01 2015 17:59
@wodCZ super cool! Try app/check <— php binary file
will check your system
Martin Janeček
@wodCZ
Dec 01 2015 18:01
@dragoonis that's great! already fixed date.timezone for fpm, didn't update cli one though
Paul Dragoonis
@dragoonis
Dec 01 2015 18:02
Did you use the PPI vagrant image? :) (use /check.php)
Martin Janeček
@wodCZ
Dec 01 2015 18:03
no, I have *.dev mapped to ~/web/*/public || ~/web/*/www so I usually just clone/create-project
Paul Dragoonis
@dragoonis
Dec 01 2015 18:04
Cool
Roman Tsiupa
@dracony
Dec 01 2015 19:52
@dragoonis have you tried integrating pixie yet =) ?