SitePoint Sponsor

User Tag List

Page 3 of 7 FirstFirst 1234567 LastLast
Results 51 to 75 of 175
  1. #51
    SitePoint Addict Mastodont's Avatar
    Join Date
    Mar 2007
    Location
    Czech Republic
    Posts
    375
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    post('username')->min_chars(4)->max_chars(6); 
    IMHO these rules should not be hard coded in an application code, I prefer config files or similar stuff.

  2. #52
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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

  3. #53
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  4. #54
    SitePoint Member Renard Urbain's Avatar
    Join Date
    Jul 2008
    Location
    Montréal, Canada
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting but there is one problem here. It manage the errors but no error message so far so you know there is an error in the form but what is the error itself it yet has to be known =)

  5. #55
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  6. #56
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  7. #57
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  8. #58
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:
        public function route($request)
        {
     
    	eval('$class = new '.$this->object.'();');
    	$class->rb = new RecordBase();
    	eval('$class->'.$this->method.'($request);');
        }

    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);
        }

  9. #59
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Changed - thank you!
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  10. #60
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    When a bit more work has been done, the method to upload is:
    PHP Code:
    upload('fieldname')->upload('uploads'); 
    To upload the file to it's same name in the uploads folder.
    PHP Code:
    upload('fieldname')->upload('uploads''upload123.txt'); 
    To upload it to uploads/upload123.txt

    (Here's the cool bit)

    PHP Code:
    upload('fieldname')
        ->
    rotate(70)
        ->
    resize(100)
        ->
    upload('uploads/images''new_file'IMAGE_JPEG
    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.

    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

  11. #61
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    I am loving the enthusiasm you are both putting into this!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  12. #62
    SitePoint Enthusiast ivanfx's Avatar
    Join Date
    May 2007
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  13. #63
    SitePoint Addict webaddictz's Avatar
    Join Date
    Feb 2006
    Location
    Netherlands
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by CoderMaya View Post
    Changed - thank you!
    CoderMaya: like I told you yesterday, you shouldn't use eval(), but I think reflection is certainly overkill for your current goals. Consider:

    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);
        } 
    and compare (benchmark, even) with:
    PHP Code:
        public function route($request)
        {
            
    $object = new {$this->object}( );
            
    $object->rb = new RecordBase( );
            
    $object->{$this->method}( );
        } 
    The second is faster and evenly tidy (if you ask me).

  14. #64
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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

  15. #65
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,396
    Mentioned
    61 Post(s)
    Tagged
    0 Thread(s)
    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?

  16. #66
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  17. #67
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Made some email functionality:

    Email example:
    simple:
    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(); 
    advanced:
    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(); 
    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!
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  18. #68
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by spikeZ View Post
    I am loving the enthusiasm you are both putting into this!
    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.

  19. #69
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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

  20. #70
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb

    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

  21. #71
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you change the vinyl LP to an 8-track?





    Kidding! It looks great!

  22. #72
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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

  23. #73
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  24. #74
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I hope that didn't get you down too much
    All advice is welcome!

    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.

    Arkinstall's email() and upload() functions that actually retrieve objects for method chaining (which I love)
    All inspired by Yam's post() function (which returns a validation object composing the value)
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  25. #75
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •