IMHO these rules should not be hard coded in an application code, I prefer config files or similar stuff.PHP Code:post('username')->min_chars(4)->max_chars(6);
| SitePoint Sponsor |


IMHO these rules should not be hard coded in an application code, I prefer config files or similar stuff.PHP Code:post('username')->min_chars(4)->max_chars(6);
Thanks for the input - I'm sure we'll do something about that soon.
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona



The current suggestion that came up is to do it both ways. To enable you to do it from code, but to also have it in an XML file and then do (because post() with no arguments returns $_POST)
post()->load('filename');
Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
Interesting but there is one problem here. It manage the errors but no error message so farso you know there is an error in the form but what is the error itself it yet has to be known =)



post_errors() will now (in build 6) return all the errors with detail.
Learn about the new Retro Framework
Code PHP the way it was meant to be coded!





In sh_read() you use file_get_contents(), but in sh_write() you use fopen()/fwrite()/fclose() instead of file_put_contents(). Is this solely for backwards compatibility, or is there some other reason?



sh_write needs to return a boolean or the number of bytes written so this is the fastest way
well in truth actually file_put_contents() does the same, but this is how the PHP developers wrote it in the manual - so it works for me. There's no big difference anyway, it does the same thing.
Last edited by CoderMaya; Sep 24, 2008 at 16:31.
Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
Great work CoderMaya, loving the concept.
Still looking over the code, but the first thing I noticed was some evil eval() usage in the route method of the router lib:
Code PHP:
Changing it to use the Reflection API makes it look a lot tidier!
Code PHP:public function route($request) { $obj = new ReflectionClass($this->object); $class = $obj->newInstance(); $class->rb = new RecordBase(); $obj->getMethod($this->method)->invoke($class, $request); }



Changed - thank you!
Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
When a bit more work has been done, the method to upload is:
To upload the file to it's same name in the uploads folder.PHP Code:upload('fieldname')->upload('uploads');
To upload it to uploads/upload123.txtPHP Code:upload('fieldname')->upload('uploads', 'upload123.txt');
(Here's the cool bit)
to rotate the image 70 degrees clockwise, resize it to have a 100px width (if no height is specified it calculates the height by the change in width) and uploads it to uploads/images/new_file.jpg.PHP Code:upload('fieldname')
->rotate(70)
->resize(100)
->upload('uploads/images', 'new_file', IMAGE_JPEG)
Cool, huh?
Oh, and theres more. You can validate the type:
PHP Code:$img = upload('image');
if($img !== false){
$img->type(IMAGE_JPEG);
if($img->is_valid()){
$img->upload('uploads/images');
}
}
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona


I am loving the enthusiasm you are both putting into this!
Mike Swiffin - Community Team Leader
Only a woman can read between the lines of a one word answer.....
I started out with nothing... and still got most of it left!
Hi guys!
Does Retro have a Form class/helper? If not, I have one done that will fit perfectly![]()
Freelance CSS and PHP developer. Using CakePHP and jQuery.


CoderMaya: like I told you yesterday, you shouldn't use eval(), but I think reflection is certainly overkill for your current goals. Consider:
and compare (benchmark, even) with:PHP Code:public function route($request)
{
$obj = new ReflectionClass($this->object);
$class = $obj->newInstance();
$class->rb = new RecordBase();
$obj->getMethod($this->method)->invoke($class, $request);
}
The second is faster and evenly tidy (if you ask me).PHP Code:public function route($request)
{
$object = new {$this->object}( );
$object->rb = new RecordBase( );
$object->{$this->method}( );
}
Yeah, it looks much tidier.
Also it's obvious what it's doing if you have a standard knowledge of PHP syntax - whereas the ReflectionClass is... well it's less known.
In fact, I'd never seen it until Logic Earth used it as a solution to passing a single string of arguments 2 days ago.
And as this framework is all about keeping things simple, I'd go for the 'new {$this->object}()' approach.
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
I'd love to see this pushed into the SVN repository, rather than being limited to just the builds that you guys release. Being able to svn co ... rather than go to site, find zip, download, extract... would be so much easier for me, plus the tracking of revisions over time (and who made them!).
Is there any particular reason(s) why you're using XML for the configuration files? Do they need to be in a transportable format?



I just like to keep configurations in XML. It's tidy. I don't think we should populate global variables if we don't have to.
Build 6 is up, but now we're gonna work on some stuff and possibly release build 7 tonight.
Learn about the new Retro Framework
Code PHP the way it was meant to be coded!
Made some email functionality:
Email example:
simple:
advanced:PHP Code:email()
->to('email@nospam.com')
->from('arkinstall@nospam.com')
->subject('My Cool Emailing Method!')
->message('Hey, look at <u>me</u>! I can mail in a simple call without stress! get with the program!')
->send();
So any guys have any thing else which annoys you when writing a PHP applicaion please say so and we'll implement a better way!PHP Code:email()
->to('email@nospam.com')
->to('anotheremail@nospam.com')
->cc('somecc@nospam.com')
->cc('someothercc@nospam.com')
->bcc('somebcc@nospam.com')
->bcc('someotherbcc@nospam.com')
->from('arkinstall@nospam.com')
->replyto('notme_mwahahaha@nospam.com')
->subject('My Cool Emailing Method!')
->message('<html><b>Hey</b>, look at <u>me</u>! I can <i>mail</i> a <em>HTML email</em> in a simple call without stress! get with the program!</html>')
->html()
->xmailer('PHP 5')
->replyto('me')
->replyto('sitepoint')
->send();
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona





So am I. It's infectious! I'm already planning to use this in a project. It's an app I've been putting off for awhile because dread of all the tedious coding that would have been involved was killing my motivation.
Which reminds me: any thoughts regarding a mascot and/or logo? I would like to put a "powered by" button on my app to make sure you guys get proper credit.
Hmm...
Well, spikez' Dave does need a home
We have a banner-ish, but no logo. Need to make it trendy but retro.
I'll work on it!
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
Haven't consulted Yam at all (he's offline at the moment) but what do you guys think of:
?
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona





Can you change the vinyl LP to an 8-track?
Kidding! It looks great!
Hope Yam likes it too![]()
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona




I really love how the project is coming along guys - great work so far.
But there is one concern I have about this project - a function naming standard must be set and adhered to. One of the most common complaints about PHP is that it's essentially just a big pool of over 3,000 functions with no set naming scheme to better group the functions. So we end up with things like 'sort', 'shuffle', 'array_merge' 'strpos', 'strlen', 'str_replace', etc. When they should have probably followed a common naming scheme like 'array_sort', 'array_shuffle', 'str_pos', etc. that would have made the function purposes and grouping much more clear.
I fear that this project may be heading down that same path already with global functions like 'find', 'record', 'single', etc. It seems to me that these should instead be either:
- Re-named to something like 'db_find', 'db_record', 'db_single', OR
- Put in an object that is retrieved with db(), like db()->find(), db()->record(), etc. like arkinstall's email() and upload() functions that actually retrieve objects for method chaining (which I love)
Great work so far guys - I hope that didn't get you down too much. Keep the enthusiasm and motivation going!
Stackbox CMS - Full edit-on-page drag-and-drop CMS
Autoridge - Vehicle information & maintenance part numbers
Twitter | Blog | Online Javascript Compressor
All advice is welcome!I hope that didn't get you down too much
We have a standard naming scheme which is:
- All functions have underscores between words, i.e. Xhtml_strict(), img_tag().
- All classes are camel cased and the first letter is also capitalised, i.e. ImageUpload
The globalised functions are have basic names for ease of use more than anything. find() does what it says on the box - and it adds to the 'light' air of Retro.
All inspired by Yam's post() function (which returns a validation object composing the value)Arkinstall's email() and upload() functions that actually retrieve objects for method chaining (which I love)![]()
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
So guys, what annoys you when writing applications?
For me it was file uploading and emailing.
Need some ideas!
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
Bookmarks