These are chat archives for ppi/framework

16th
Feb 2016
Mark
@sephedo
Feb 16 2016 22:35
Evening all, just been on github for PPI and i know its a little niggle but your documentation link on your README.md link is pointing to the wrong place :)
Paul Dragoonis
@dragoonis
Feb 16 2016 22:35
@sephedo really? we patched up a few links the other day. let me take a look
nice to meet you @sephedo :)
Mark
@sephedo
Feb 16 2016 22:36
You too @dragoonis, i was at the PHPminds meet last thursday
Paul Dragoonis
@dragoonis
Feb 16 2016 22:36
I see the docs issue now. Patching.
Alfredo Juárez
@alfrekjv
Feb 16 2016 22:37
Hey guys!
Mark
@sephedo
Feb 16 2016 22:37
Thanks Paul
Paul Dragoonis
@dragoonis
Feb 16 2016 22:37
@sephedo fixed for master and 2.1 - points to here now - http://docs.ppi.io/
evening @alfrekjv
Mark
@sephedo
Feb 16 2016 22:38
Cheers got the docs from the main ppi.io site thought i would point it out just about to start working through them#
Alfredo Juárez
@alfrekjv
Feb 16 2016 22:38
How're things going, @dragoonis?
Paul Dragoonis
@dragoonis
Feb 16 2016 22:39
@sephedo yea, kewl. I am in the process right now of removing a lot of bloat from the docs ;) and adding more code examples ;)
Mark
@sephedo
Feb 16 2016 22:39
Awesome, ill let you know any feedback i have as i go through them
Paul Dragoonis
@dragoonis
Feb 16 2016 22:39
@sephedo module:create wizard is your friend here if you want to whip up a new feature consisting of your chosen tools
I’m going to make a new release now (2.1.2) for Aura router fix and update the website.
Paul Dragoonis
@dragoonis
Feb 16 2016 22:47
All done :) 2.1.2 released :) http://ppi.io/downloads
/cc @noisebleed
Mark
@sephedo
Feb 16 2016 23:08
Lol have to update composer now :P
Paul Dragoonis
@dragoonis
Feb 16 2016 23:09
@sephedo shortcut
composer update ppi/framework
Mark
@sephedo
Feb 16 2016 23:10
Just ran that :)
Paul Dragoonis
@dragoonis
Feb 16 2016 23:10
:clap:
Paul Dragoonis
@dragoonis
Feb 16 2016 23:19
@sephedo I’ve just published new docs for the Services section - it’s basically taking examples from my talk at PHPMiNDS and putting it up on the interwebs :) http://docs.ppi.io/latest/book/services.html
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:24
@dragoonis do you have a doc/tutorial/sample-code to create a CLI app on PPI?
Paul Dragoonis
@dragoonis
Feb 16 2016 23:24
@alfrekjv I made screencasts (http://www.ppi.io/screencasts/) - but just run “module:create” and it’s a nice wizard
the screencasts are a little out of date as the wizard as matured onward since I made them
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:25
Great! Thanks!
Paul Dragoonis
@dragoonis
Feb 16 2016 23:25
Just download 2.1.2 and give it a spin!
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:25
will do, thanks!
Paul Dragoonis
@dragoonis
Feb 16 2016 23:25
@alfrekjv actually look at this slide - http://talks.ppi.io/20160211-phpminds/#/69 - and the next one
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:26
I have some cron-jobs that I run, but I use curl, I figured it would be better to have it as a CLI script instead..
Paul Dragoonis
@dragoonis
Feb 16 2016 23:26
@alfrekjv sorry I thought you said CLI for making PPI Modules
PPI uses symfony console so you can place any symfony command class in ./modules/MyModule/Command/ DIR and it will be availabel via app/console
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:27
Oh my bad
Paul Dragoonis
@dragoonis
Feb 16 2016 23:27
we “listen” for your command classes
./modules/*/Command/*Command.php
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:27
Roger
That makes more sense :)
Paul Dragoonis
@dragoonis
Feb 16 2016 23:28
You can drop in any existing symfony command, or your own custom ones in there and it’ll run just fine :)
I will try to make docs on this actually :)
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:29
I can share the result, if you want :smile:
how do you call it? php app/console command-name arguments
?
Paul Dragoonis
@dragoonis
Feb 16 2016 23:30
type app/console and all the available commands will be shown to you
if it’s not in app/console output, it’s not found it
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:31
Okay
Paul Dragoonis
@dragoonis
Feb 16 2016 23:31
I am reading the framework code now to figure out how it works (then I will document it :D) @noisebleed added it.
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:32
Do you need to register it some where?
Paul Dragoonis
@dragoonis
Feb 16 2016 23:32
As I was saying, it’s not necessary, give me 60 seconds to come back with the correct answer
doing some grep’ing ;)
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:32
haha Okay
I created a Class under Application\Command\Queue.php
Paul Dragoonis
@dragoonis
Feb 16 2016 23:33
found it
\PPI\Framework\Module\AbstractModule::registerCommands
Paul Dragoonis
@dragoonis
Feb 16 2016 23:34
looks like you pass it Application instance and then it auto-magically lookds for /Command/ files and registrs them for you
aha!!
when app/consoel boots - it calls \PPI\Framework\Console\Application::registerCommands
which does
        foreach ($this->app->getModules() as $module) {
            if ($module instanceof AbstractModule) {
                $module->registerCommands($this);
            }
        }
and registerCommands() does
        if (!is_dir($dir = $this->getPath() . '/Command')) {
            return;
        }
        $finder = new Finder();
        $finder->files()->name('*Command.php')->in($dir);
        foreach ($finder as $file) {
following how/why it works ?
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:36
So, the file needs to be called SomethingCommand.php
Paul Dragoonis
@dragoonis
Feb 16 2016 23:36
Yes, symfony convention
and looks like you need it in /modules/MyModule/Command/ DIR - which isn’t so clean since I keep my code in ./modules/MyModule/src/Command
Still - this will work just fine for you, i’m just being picky :P
1. rename Queue to QueueCommand.php
2. put it in modules/YourModule/Command/QueueCommand.php
3. run app/console and you should see queue:post
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:40
not appearing
Paul Dragoonis
@dragoonis
Feb 16 2016 23:40
show me your Module.php
also, are you on PPI 2.1.0, 2.1.1, 2.1.2 ?
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:41
:D
2.0 :$
Paul Dragoonis
@dragoonis
Feb 16 2016 23:41
Show me your module.php
Show me your QueueCommand.php
Paul Dragoonis
@dragoonis
Feb 16 2016 23:44
run tree modules/Application command on linux and show me the output
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:45
$ tree modules/Application
-bash: tree: command not found
Paul Dragoonis
@dragoonis
Feb 16 2016 23:46
macbook? ubuntu?
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:46
Macbook
Paul Dragoonis
@dragoonis
Feb 16 2016 23:46
brew install tree
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:46
installing
Paul Dragoonis
@dragoonis
Feb 16 2016 23:47
ok, pop open vendor/ppi/framework
go here - \PPI\Framework\Module\AbstractModule::registerCommands
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:49
That's the problem :D
there's no AbstractModule.php file.
Paul Dragoonis
@dragoonis
Feb 16 2016 23:49
@alfrekjv i mis-read - it’s not in 2.0 - touch luck dude :P
manually register yourself in app/console file
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:49
ok, it seems like this is the perfect pretext to upgrade to 2.1
haha
Paul Dragoonis
@dragoonis
Feb 16 2016 23:50
@alfrekjv indeed, but meanwhile you can manually add it
$application->add(new QueueCommand());
boom :shipit:
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:50
Perfect
php app/console
PHP Fatal error: Class 'Application\Command\QueueCommand' not found in /Users/alfrekjv/Sites/pulpin/app/console on line 19
$application->add(new \Application\Command\QueueCommand());
Paul Dragoonis
@dragoonis
Feb 16 2016 23:52
well, interesting, your Application namespace doesn’t exist at this point
since Module::init() registers it
Solution: move your autoload out of your Module::init() and move it into composer.json, then it will be available immediately
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:54
Let me see if I understood :D
Paul Dragoonis
@dragoonis
Feb 16 2016 23:54
composer.json —> autoload section PSR-0 or PSR-4 -> composer update; composer dump-autoload
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:55
What do I have to remove from app/init.php ?
Paul Dragoonis
@dragoonis
Feb 16 2016 23:55
Nothing
remove your Application\Module::init() method. You no longer need it, since you’re going to setup autoloading for “Application” namespace from your composer.json - following?
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:56
roger
"autoload": {
'QueueCommand': "\Application\Command\QueueCommand"
}
something like that?
Paul Dragoonis
@dragoonis
Feb 16 2016 23:56
LOL
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:57
😰
  "autoload": {
    "psr-4": {
      "Application\\": "modules/Application/"
    }
Alfredo Juárez
@alfrekjv
Feb 16 2016 23:59
Ok, running composer update;
Paul Dragoonis
@dragoonis
Feb 16 2016 23:59
thus
new Application\Command\QueueCommand
—>
modules/Application/Command/QueueCommand.php