webdevRefinery Forum: Hydrogen Templates for Front-End Developers - webdevRefinery Forum

Jump to content

Hydrogen what, now?

Hydrogen is an open-source PHP toolkit that focuses on speed, with the goal of making your webapps faster if they're built on Hydrogen then they would be if written from scratch. It was created to be portable: applications written on Hydrogen should be able to be installed on many different types of servers with different database types or cache engines without changing any code or doing any extra programming work.

This forum contains the official tutorials for Hydrogen, until Hydrogen reaches version 1.0 and they move to HydrogenPHP.com. Please feel free to comment on them if you need help understanding them, or contribute your own tutorials that might later be published on the official site!
  • 8 Pages +
  • 1
  • 2
  • 3
  • 4
  • 5
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

User is offline devinsba 

  • Group: Members
  • Posts: 116
  • Joined: 08-August 10
  • LocationClarkson University
  • Expertise:PHP,Java,Javascript

Posted 31 December 2010 - 01:10 AM (#41)

View PostKyek, on 31 December 2010 - 01:05 AM, said:

Is the dump not showing all the child properties? I'm not seeing the "widget" or "module" fields you refer to in the template.


they are methods, getModule and getWidget, I kindof cheated your use of automatically trying different methods, link to full class below

https://github.com/d...ugin/Plugin.php
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 31 December 2010 - 07:21 AM (#42)

Ah, my bad xD Lordy, you'd think I'd know my own code better than this ;-)
0


User is online Koen 

  • Leroy Jenkins
  • Group: Members
  • Posts: 2503
  • Joined: 10-March 10
  • Locationthe Netherlands
  • Expertise:HTML,CSS,Javascript,Graphics

Posted 31 December 2010 - 01:43 PM (#43)

I've made a filter to parse filesizes, feed it the filesize in bytes and it'll return a string with a nicely formatted filesize.

Source:
Spoiler

Please click the + if I helped you!
Twitter: @KoenKlaren

<callumacrae> YOU DID A ROMNEY
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 31 December 2010 - 01:53 PM (#44)

Sweet! A few pointers:
  • For Django compatibility, let's name it 'filesizeformat'. Might make someone's life easier when switching to Hydrogen from some other engine :)
  • The parser will automatically convert all filters to lowercase and cap the first character when looking for the class name. So instead of FileSizeFormatFilter, you'd want FilesizeformatFilter. I know, it looks a lot less clean, but otherwise I'd have to get the directory listing of all the filters to compare case-insensitive, and that'd be way slow.
  • Optimize! $var / 1024 / 1024 looks good, but you can cut out an operation there. It may not seem like much, but for someone with 200 file size listings, that definitely has an impact :)
  • The $code argument of PHPFile->addFunction puts the { and } in for you -- no need to put that in your code :). Props on learning to use that with zero documentation, though!

Cover all that, and if you send me a pull request on github, this will definitely go in under your name :)
0


User is online Koen 

  • Leroy Jenkins
  • Group: Members
  • Posts: 2503
  • Joined: 10-March 10
  • Locationthe Netherlands
  • Expertise:HTML,CSS,Javascript,Graphics

Posted 31 December 2010 - 01:55 PM (#45)

View PostKyek, on 31 December 2010 - 01:53 PM, said:

Sweet! A few pointers:
  • The $code argument of PHPFile->addFunction puts the { and } in for you -- no need to put that in your code :). Props on learning to use that with zero documentation, though!


It does not :)

For the other points, will do!

Edit: New source:
Spoiler

Please click the + if I helped you!
Twitter: @KoenKlaren

<callumacrae> YOU DID A ROMNEY
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 31 December 2010 - 02:27 PM (#46)

View PostPWNbear, on 31 December 2010 - 01:55 PM, said:

It does not :)
Goddamn, it should. Checking it out ;-)

Quote

For the other points, will do!
Looks fantastic! If you've tested all the edge cases and it's working, send me a pull request on github!
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 01 January 2011 - 11:20 AM (#47)

View Postdevinsba, on 31 December 2010 - 12:45 AM, said:

I am still getting the Undefined Offset: 1 warning in ContextStack. This seems to be called in these for loops

Ok, I *think* I got this covered. I definitely fixed a bug with for loops, I'm just not sure if that's the bug you were running into or not. If it still doesn't work after you update, let me know and I'll play around a bit more. Might have to wait until you can grab that stack trace, though :)
0


User is offline devinsba 

  • Group: Members
  • Posts: 116
  • Joined: 08-August 10
  • LocationClarkson University
  • Expertise:PHP,Java,Javascript

Posted 01 January 2011 - 07:07 PM (#48)

View PostKyek, on 01 January 2011 - 11:20 AM, said:

Ok, I *think* I got this covered. I definitely fixed a bug with for loops, I'm just not sure if that's the bug you were running into or not. If it still doesn't work after you update, let me know and I'll play around a bit more. Might have to wait until you can grab that stack trace, though :)


That was it, awesome :)
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 01 January 2011 - 10:00 PM (#49)

Kickass =D

View PostKyek, on 31 December 2010 - 02:27 PM, said:

Looks fantastic! If you've tested all the edge cases and it's working, send me a pull request on github!

psst, pwn-- I can take your code and commit it into the repo myself, but then it won't have your name on it. I'd like to whip up a release soon, though, so just tell me which you'd like to do :)
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 02 January 2011 - 12:14 AM (#50)

Double-posting to announce 10 new filters added to the documentation :)

The latest update now includes: DATE, DEFAULT, FIRST, JOIN, LAST, LENGTH, LENGTH_IS, LINEBREAKS, LINEBREAKSBR, SLUGIFY. Enjoy :)
0


User is offline Mo3 

  • Awesomeness on Rails
  • Group: Moderators
  • Posts: 1957
  • Joined: 21-July 10
  • LocationBavaria
  • Expertise:PHP,Java,Javascript,Python,Ruby on Rails,Node.js

Posted 02 January 2011 - 02:38 AM (#51)

So, Kyek, any news on the first official release? :)
Ruby on Rails | Python | PHP
What is necessary to change a person is to change his awareness of himself.
0


User is online Koen 

  • Leroy Jenkins
  • Group: Members
  • Posts: 2503
  • Joined: 10-March 10
  • Locationthe Netherlands
  • Expertise:HTML,CSS,Javascript,Graphics

Posted 02 January 2011 - 04:29 AM (#52)

View PostKyek, on 02 January 2011 - 12:14 AM, said:

Double-posting to announce 10 new filters added to the documentation :)

The latest update now includes: DATE, DEFAULT, FIRST, JOIN, LAST, LENGTH, LENGTH_IS, LINEBREAKS, LINEBREAKSBR, SLUGIFY. Enjoy :)

If you tell me how to do a pull request :)

You have a typo in the linebreaksbr filter, the code you use uses the linebreaks filter.

BTW is there a way to get these filters inside my controller? I don't want to copy that filesize function so my controller can send the nicely formatted size to the client. I'm using JSON and I don't want to use an entire view for generating the JSON-string.
Please click the + if I helped you!
Twitter: @KoenKlaren

<callumacrae> YOU DID A ROMNEY
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 02 January 2011 - 09:03 AM (#53)

View PostPWNbear, on 02 January 2011 - 04:29 AM, said:

If you tell me how to do a pull request :)

You would need a Github account, then you'd want to fork Hydrogen (so you have your own branch of Hydrogen on Github), commit your new file, then hit the link in Github to send a pull request for your commit :).

If you haven't already set git up to use Github as a remote repo, there are all kinds of getting started guides here: http://help.github.com

Quote

You have a typo in the linebreaksbr filter, the code you use uses the linebreaks filter.

Thanks! Fixed :)

Quote

BTW is there a way to get these filters inside my controller? I don't want to copy that filesize function so my controller can send the nicely formatted size to the client. I'm using JSON and I don't want to use an entire view for generating the JSON-string.

Well, the thing is, the Filter classes are for generating PHP code that will apply the filter in the future -- and if you wanted to do that in the controller layer (which should actually probably be in a model, since you're transforming data), you'd need a function that applies that filter right now and doesn't generate PHP code. So if you would write that function into a model, it wouldn't be a duplication of code, because the filter and the pure function do completely different things :)

View PostMo3, on 02 January 2011 - 02:38 AM, said:

So, Kyek, any news on the first official release? :)

Pulling this from another thread :)

View PostKyek, on 28 December 2010 - 08:00 AM, said:

Here's the roadmap to 1.0:
  • Complete templates. This one is practically done, but I need a test period of people using it to help find bugs and suggest tags that I really need to add in before it goes to a full release.
  • Rewrite the Query library. It's just too heavy. The syntax will be pretty similar to what it is now, but the performance will be much better. There are some notes on this in my thread about the new SQLBeans. And on that note...
  • Rewrite SQLBeans. This one will be a complete overhaul, but I don't think it's going to be too awful hard.
  • Finish in-code documentation. Some classes have fantastic PHPDoc-style documentation in them, others don't have any. I need to write up what each function and class does so that it's easier for people to get into the code.
  • Create the website and write the docs for using Hydrogen. I just need some guides on how to get going with Hydrogen that are split up and more easy to understand than the overview thread here ;-). I may not hold off 1.0 for this, but it would be really nice if they could coincide and I could hit the ground running as far as suggesting the library to people and pointing them toward the Getting Started guides.
  • Create a project generator. Like the above, this may not hold off 1.0, but I'd like it to be there for 1.0 if I can. I just want a system where people can type in their project name and click a button to download a .zip file "starter" project. They'd be able to select whether they're writing an MVC app, a static site that they just want to use templates for, or maybe a different type of configuration, and they get back a zip file with their project already started so they see the best way to organize it.
  • Release 1.0.


I'm not putting out any timelines yet since my free time is notoriously fickle, but I'd really love to get this thing out the door as soon as possible. Another thing I'd like to do before 1.0 is speed test Hydrogen against other frameworks to make damn good and certain that Hydrogen is the fastest thing out there, and also to get stats that I can make bar graphs with to brag about it on the homepage :D

0


User is online Koen 

  • Leroy Jenkins
  • Group: Members
  • Posts: 2503
  • Joined: 10-March 10
  • Locationthe Netherlands
  • Expertise:HTML,CSS,Javascript,Graphics

Posted 02 January 2011 - 10:02 AM (#54)

Sent the pull request :)
Please click the + if I helped you!
Twitter: @KoenKlaren

<callumacrae> YOU DID A ROMNEY
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 02 January 2011 - 10:25 AM (#55)

Merged into core :) Welcome to the contributors listing! https://github.com/T...en/contributors

(Also, fixed that thing where you had to put your own braces around function code. That's no longer required.)
0


User is online Koen 

  • Leroy Jenkins
  • Group: Members
  • Posts: 2503
  • Joined: 10-March 10
  • Locationthe Netherlands
  • Expertise:HTML,CSS,Javascript,Graphics

Posted 02 January 2011 - 10:26 AM (#56)

View PostKyek, on 02 January 2011 - 10:25 AM, said:

Merged into core :) Welcome to the contributors listing! https://github.com/T...en/contributors

Awesome :D
Please click the + if I helped you!
Twitter: @KoenKlaren

<callumacrae> YOU DID A ROMNEY
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 02 January 2011 - 11:29 AM (#57)

Added the documentation :) I tweaked it a bit to allow people to specify the number of decimal places they want it to go to, but the default is still 2 if they don't.
0


User is offline derTechniker 

  • BadBoy™
  • Group: Members
  • Posts: 1210
  • Joined: 06-July 10
  • LocationAustria
  • Expertise:HTML,CSS,PHP,Javascript,SQL

Posted 02 January 2011 - 11:35 AM (#58)

I really hope there is an option to either show it in american style like "1.2GB" or in german style "1,2GB" or in one of the others ;)
0


User is online Koen 

  • Leroy Jenkins
  • Group: Members
  • Posts: 2503
  • Joined: 10-March 10
  • Locationthe Netherlands
  • Expertise:HTML,CSS,Javascript,Graphics

Posted 02 January 2011 - 11:36 AM (#59)

View PostderTechniker, on 02 January 2011 - 11:35 AM, said:

I really hope there is an option to either show it in american style like "1.2GB" or in german style "1,2GB" or in one of the others ;)

I think Kyek's implementing that right now :P
Please click the + if I helped you!
Twitter: @KoenKlaren

<callumacrae> YOU DID A ROMNEY
0


User is offline Kyek 

  • Founder of wdR
  • Group: Administrators
  • Posts: 5082
  • Joined: 20-February 10
  • LocationPhiladelphia, PA, USA
  • Expertise:HTML,CSS,PHP,Java,Javascript,Node.js,SQL

Posted 02 January 2011 - 11:48 AM (#60)

Tweaked it again to support the full featureset of the Django version :) It now handles "bytes" and "TB", and will remove trailing zeros (so 54.200 GB becomes 54.2 GB).

View PostderTechniker, on 02 January 2011 - 11:35 AM, said:

I really hope there is an option to either show it in american style like "1.2GB" or in german style "1,2GB" or in one of the others ;)

There isn't yet-- I didn't make that an argument in the filter itself because this will be part of the i18n library I'm writing :) The decimal point and thousands separator will match whatever locale you have in your config file. Not sure when the i18n package will be done ... but this filter will be changed to use it whenever it is :)
0


Share this topic:


  • 8 Pages +
  • 1
  • 2
  • 3
  • 4
  • 5
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services