Skip to content
This repository was archived by the owner on Jan 1, 2020. It is now read-only.

Added Template Map Generator #340

Conversation

RalfEggert
Copy link

Added template map geneartor to solve #334

* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2016

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please leave these things out of the skeleton? Seems excessive to
me, at least...
On Jun 12, 2016 2:17 PM, "Abdul Malik Ikhsan" notifications@github.com
wrote:

In bin/templatemap_generator.php
#340 (comment)
:

@@ -0,0 +1,256 @@
+#!/usr/bin/env php
+<?php
+/**

https://github.com/zendframework/ZendSkeletonApplication


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/zendframework/ZendSkeletonApplication/pull/340/files/96faacadc30c73e013b3b5470de7acf968652da8#r66720133,
or mute the thread
https://github.com/notifications/unsubscribe/AAJakBO_Kc3-gGKPRsl6Csr-fIZqyJGxks5qK_jhgaJpZM4Izev-
.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But where should the template map generator be placed then? It doesn't make sense to add the zendframework/zendframework package just to get the template map generator. Create a new package just for the generator? Seems excessive to me... ;-)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thought about it a little more. How about adding the template map generator to https://github.com/zendframework/zend-view?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @Ocramius comment is about placing license header, not about where template map generator

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RalfEggert I like that idea; that puts it in the same repo that would consume what it generates.

If you do this, don't forget to add the bin entry for it in the composer.json (per the Vendor Binaries documentation). Usage would be like any other installed binary: ./vendor/bin/templatemap_generator.php ....

Ping me when you have a PR! 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weierophinney

Here you go: zendframework/zend-view#65

I hope everything is ok, since I am sitting in a train home and don't have access to my main note book. I only have a windows machine here right now.

I guess this PR can be closed if you accept the one at zend-view

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @Ocramius comment is about placing license header, not about where template map generator

No, I actually am against having the template map generator in the skeleton.

First of all, it could live in a separate module, like all other MVC-ish modules in here.
Second, I already built something that completely removes the need for a template map, and is compatible with v3 - https://github.com/Ocramius/OcraCachedViewResolver

This, in my opinion, is micro-optimization and complication.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius

Well, the template map generator will be moved to zend-view, anyway.

I like your OcraCachedViewResolver but since it requires PHP 7 it is no alternative as long as ZF3 components have a minimum requirement of PHP 5.6.

@vrkansagara
Copy link

vrkansagara commented Jun 14, 2016

@Ocramius is right ! 👍

*/

use Zend\Console;
use Zend\Loader\StandardAutoloader;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This last import statement can be removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which brings me to an interesting dilemma... The script makes use of Zend\Console\Getopt, which would mean that zend-view would need to add zend-console as a dependency, which I doubt we want to do.

I think we could likely simplify the script to have the signature:

$ templatemap_generator.php <directory>

and have it spit what it generates to STDOUT; developers can then pipe that to a file. As an example, to overwrite:

$ templatemap_generator.php module/Album/view > config/autoload/views.global.php

To append:

$ templatemap_generator.php module/Album/view >> config/autoload/views.global.php

Alternately, we could require that they pass the full set of files via globbing, which would accommodate the current --extensions argument:

$ templatemap_generator.php module/Album/view/**/*.phtml >> module/Album/config/template_map.php

If the script assumes that the map should be relative to the PWD, then we could suggest this workflow:

$ cd module/Album/view
$ ../../../vendor/bin/templatemap_generator.php ./**/*.phtml > ../config/template_map.php

Calling the script with no arguments or with --help or -h would provide the usage message.

The above essentially accommodates all current options, and would allow eliminating the dependency on zend-console; we'd only have to parse $argv and grab the first argument.

Thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add this discussion to the zendframework/zend-view#65?

@RalfEggert
Copy link
Author

Fixed by zendframework/zend-view#67

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants