librelist archives

« back to archive

[PDP] Compiled Template Class Name Change

[PDP] Compiled Template Class Name Change

From:
Loic d'Anterroches
Date:
2011-07-15 @ 08:03
Hello,

as I am nearly finishing the compilation of the templates inside the
.phar at packaging time, I need to chengae the name of the generated class.

At the moment, the name is also dependend of the template folders, the
code to generate it is based on a unique uid derived from the template
path - ex: '/yourapp/yourstuff/foo.html' - and the folders where to find
the templates - ex: array('/here/templates', '/there/some/others'). The
uid is then:

 $uid = md5(var_export($folders, true) . $template);

The class name is then:

 $class = '\photon\template\compiled\Template_' . $uid;

Now, the problem is the $folders. It does not make sense when everything
is packaged and compiled in the .phar. Especially because you compile
*locally* and deploy *remotely*. It means different folders and then a
missmatch in the class name and an error.

My proposal is to only use the template name to generate the class name:

 $uid = md5($template);

and skip the compilation step to directly load the with the auto loader
if within the .phar.

What you will need to pay attention too:

- one cache folder per project or your may get one project overwritting
the compiled template of the other (if not run from .phar).
- no dynamic change of the folder paths during execution.

Normally, this is not something one does, so it should be ok.

Feedback welcome,
loïc

--
Indefero - Project management and code hosting - http://www.indefero.net
Photon - High Performance PHP Framework - http://photon-project.com
Céondo Ltd - Web + Science = Fun - http://www.ceondo.com

Re: [photon.users] [PDP] Compiled Template Class Name Change

From:
Loic d'Anterroches
Date:
2011-07-15 @ 09:39
Hello,

ok, I have it working. I must say, this is really nice, you can now
package the full project in the .phar and run everything from a read
only file system.

It will be time to improve the documentation because now we really have
something robust and possibly game changing in the way one
creates/deploys PHP applications.

Pushing in the repository all the code during the day,
loïc

On 2011-07-15 10:03, Loic d'Anterroches wrote:
> Hello,
> 
> as I am nearly finishing the compilation of the templates inside the
> .phar at packaging time, I need to chengae the name of the generated class.
> 
> At the moment, the name is also dependend of the template folders, the
> code to generate it is based on a unique uid derived from the template
> path - ex: '/yourapp/yourstuff/foo.html' - and the folders where to find
> the templates - ex: array('/here/templates', '/there/some/others'). The
> uid is then:
> 
>  $uid = md5(var_export($folders, true) . $template);
> 
> The class name is then:
> 
>  $class = '\photon\template\compiled\Template_' . $uid;
> 
> Now, the problem is the $folders. It does not make sense when everything
> is packaged and compiled in the .phar. Especially because you compile
> *locally* and deploy *remotely*. It means different folders and then a
> missmatch in the class name and an error.
> 
> My proposal is to only use the template name to generate the class name:
> 
>  $uid = md5($template);
> 
> and skip the compilation step to directly load the with the auto loader
> if within the .phar.
> 
> What you will need to pay attention too:
> 
> - one cache folder per project or your may get one project overwritting
> the compiled template of the other (if not run from .phar).
> - no dynamic change of the folder paths during execution.
> 
> Normally, this is not something one does, so it should be ok.
> 
> Feedback welcome,
> loïc
> 
> --
> Indefero - Project management and code hosting - http://www.indefero.net
> Photon - High Performance PHP Framework - http://photon-project.com
> Céondo Ltd - Web + Science = Fun - http://www.ceondo.com

Re: [photon.users] [PDP] Compiled Template Class Name Change

From:
William Martin
Date:
2011-07-15 @ 13:05
It's maybe time increase the version number, and start a new beta ;)

On Fri, Jul 15, 2011 at 11:39 AM, Loic d'Anterroches <loic@ceondo.com> wrote:
> Hello,
>
> ok, I have it working. I must say, this is really nice, you can now
> package the full project in the .phar and run everything from a read
> only file system.
>
> It will be time to improve the documentation because now we really have
> something robust and possibly game changing in the way one
> creates/deploys PHP applications.
>
> Pushing in the repository all the code during the day,
> loïc
>
> On 2011-07-15 10:03, Loic d'Anterroches wrote:
>> Hello,
>>
>> as I am nearly finishing the compilation of the templates inside the
>> .phar at packaging time, I need to chengae the name of the generated class.
>>
>> At the moment, the name is also dependend of the template folders, the
>> code to generate it is based on a unique uid derived from the template
>> path - ex: '/yourapp/yourstuff/foo.html' - and the folders where to find
>> the templates - ex: array('/here/templates', '/there/some/others'). The
>> uid is then:
>>
>>  $uid = md5(var_export($folders, true) . $template);
>>
>> The class name is then:
>>
>>  $class = '\photon\template\compiled\Template_' . $uid;
>>
>> Now, the problem is the $folders. It does not make sense when everything
>> is packaged and compiled in the .phar. Especially because you compile
>> *locally* and deploy *remotely*. It means different folders and then a
>> missmatch in the class name and an error.
>>
>> My proposal is to only use the template name to generate the class name:
>>
>>  $uid = md5($template);
>>
>> and skip the compilation step to directly load the with the auto loader
>> if within the .phar.
>>
>> What you will need to pay attention too:
>>
>> - one cache folder per project or your may get one project overwritting
>> the compiled template of the other (if not run from .phar).
>> - no dynamic change of the folder paths during execution.
>>
>> Normally, this is not something one does, so it should be ok.
>>
>> Feedback welcome,
>> loïc
>>
>> --
>> Indefero - Project management and code hosting - http://www.indefero.net
>> Photon - High Performance PHP Framework - http://photon-project.com
>> Céondo Ltd - Web + Science = Fun - http://www.ceondo.com
>



-- 
---------------------------------------------------------
William MARTIN
wysman @NoSpAm@ gmail @DoT@ com

Re: [photon.users] [PDP] Compiled Template Class Name Change

From:
Loic d'Anterroches
Date:
2011-07-15 @ 15:12

On 2011-07-15 15:05, William MARTIN wrote:
> It's maybe time increase the version number, and start a new beta ;)

I need to write the doc and update the unit tests, only 97% coverage at
the moment.

But yes, time to do it.

loïc

> On Fri, Jul 15, 2011 at 11:39 AM, Loic d'Anterroches <loic@ceondo.com> wrote:
>> Hello,
>>
>> ok, I have it working. I must say, this is really nice, you can now
>> package the full project in the .phar and run everything from a read
>> only file system.
>>
>> It will be time to improve the documentation because now we really have
>> something robust and possibly game changing in the way one
>> creates/deploys PHP applications.
>>
>> Pushing in the repository all the code during the day,
>> loïc
>>
>> On 2011-07-15 10:03, Loic d'Anterroches wrote:
>>> Hello,
>>>
>>> as I am nearly finishing the compilation of the templates inside the
>>> .phar at packaging time, I need to chengae the name of the generated class.
>>>
>>> At the moment, the name is also dependend of the template folders, the
>>> code to generate it is based on a unique uid derived from the template
>>> path - ex: '/yourapp/yourstuff/foo.html' - and the folders where to find
>>> the templates - ex: array('/here/templates', '/there/some/others'). The
>>> uid is then:
>>>
>>>  $uid = md5(var_export($folders, true) . $template);
>>>
>>> The class name is then:
>>>
>>>  $class = '\photon\template\compiled\Template_' . $uid;
>>>
>>> Now, the problem is the $folders. It does not make sense when everything
>>> is packaged and compiled in the .phar. Especially because you compile
>>> *locally* and deploy *remotely*. It means different folders and then a
>>> missmatch in the class name and an error.
>>>
>>> My proposal is to only use the template name to generate the class name:
>>>
>>>  $uid = md5($template);
>>>
>>> and skip the compilation step to directly load the with the auto loader
>>> if within the .phar.
>>>
>>> What you will need to pay attention too:
>>>
>>> - one cache folder per project or your may get one project overwritting
>>> the compiled template of the other (if not run from .phar).
>>> - no dynamic change of the folder paths during execution.
>>>
>>> Normally, this is not something one does, so it should be ok.
>>>
>>> Feedback welcome,
>>> loïc
>>>
>>> --
>>> Indefero - Project management and code hosting - http://www.indefero.net
>>> Photon - High Performance PHP Framework - http://photon-project.com
>>> Céondo Ltd - Web + Science = Fun - http://www.ceondo.com
>>
>