TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-29-2009, 02:50 PM   #21 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Sure thing Kalle, consider it done... now.
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 03-30-2009, 05:10 PM   #22 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

Quote:
Originally Posted by Tanax View Post
Offtopic- How did you get @ php . net mail?
I contribute to abit of all on php.net, the php source, extensions, website, documentation and translations. Basiclly all except for PEAR & GTK.


Edit; I tried to browse the website a few times but it seems to timeout all the time :/
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 03-31-2009, 12:41 AM   #23 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Quote:
Edit; I tried to browse the website a few times but it seems to timeout all the time :/
Odd, it seems to be working just fine for me... Anyone else having trouble with the site?

Btw I'm in the process of uploading a new version of the framework. Same thing, just with a few fixes.

EDIT: New version uploaded
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 03-31-2009, 05:59 AM   #24 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

I notices alot of things, alot of neatpicking but some could really be improved:
  • You are using double quotes for many things that doesn't use string interpolation, this is slower because php will seek through the string to find replacables, therefore use single quotes
  • PHP Code:
    @define("PATH_INFO",$_SERVER['PATH_INFO']); 
    define will *not* emit an error, plus many SAPI's will not define PATH_INFO (for example Apache2 must have AcceptPathInfo = On), I know you have a note above saying so but perhaps find a more cross platform solution if possible
  • PHP Code:
    $url $route["$url"]; 
    Related to the comment about string interpolation, you don't need php to spend extra time searching the string to replace one value you don't concate with something else, so simply use:
    PHP Code:
    $url $route[$url]; 
  • PHP Code:
    if(!empty($route[preg_replace('/^(\/)/','',$url)])) 
    without testing it, it looks like this would emit an E_NOTICE because the value may not exist in the $route array
  • PHP Code:
    if(is_array(!empty($plugin))) 
    This expression is not logical value, the value you pass to is_array() is the value of an expression meaning the value is a boolean and therefore it can never be an array
  • PHP Code:
    $x += 1
    , you can use pre/post fixes here, not that it plays a big deal:
    PHP Code:
    $x++; 
  • PHP Code:
    eval("\$_controller->{$url[1]}($arguments);"); 
    this can be very very dangerous, php already supports variable functions, functors and so on, use the call_user_func[_array] functions and don't build arguments in a string but rather an array and run it like:
    PHP Code:
    call_user_func_array(Array($_controller$url[1]), $arguments); 

That was just a few by reading over the boostrap, I would also use __autoload()/spl_autoload_register() to define an autoloader and load classes only as they are needed. Secondly I would register a default exception handler and then throw exceptions instead of calling $dingo->error() all the time, and then make the exception handler format the error type depending on the exception, SPL offers alot of standard exceptions you can use and they can be found here.


ps. your changelog is a .ini, but its not a real ini file?


Edit; whops, seems like I came to add a bogus entry :)
__________________

Last edited by Kalle : 03-31-2009 at 03:49 PM.
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 03-31-2009, 04:57 PM   #25 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Quote:
define will *not* emit an error, plus many SAPI's will not define PATH_INFO (for example Apache2 must have AcceptPathInfo = On)
The '@' is there to prevent an error from $_SERER['PATH_INFO'] which, oddly, sometimes gives an error even whe it is present.

PHP Code:
if(!empty($route[preg_replace('/^(\/)/','',$url)])) 
Does not produce an E_NOTICE error.

PHP Code:
eval("\$_controller->{$url[1]}($arguments);"); 
Quote:
this can be very very dangerous, php already supports variable functions, functors and so on, use the call_user_func[_array] functions and don't build arguments in a string but rather an array and run it like:
PHP Code:
call_user_func_array(Array($_controller$url[1]), $arguments); 
Thanks, I'll try that

Quote:
ps. your changelog is a .ini, but its not a real ini file?
Lol, actually I did that because it is easier to read in my text editor. I should probably change that! I'll also see about little performance enhancements like changing double quotes to single quotes.

So, any thoughts on the the framework from a application developers perspective? Like, how controllers work, how you access views, ect...
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 03-31-2009, 06:06 PM   #26 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by ETbyrne View Post
The '@' is there to prevent an error from $_SERER['PATH_INFO'] which, oddly, sometimes gives an error even whe it is present.
There should never be an error if it is present. However, if the value is not present a NOTICE will be raised and the define will assign NULL. If you are getting an error, is it repeatable and under what circumstances does it occur?


Quote:
Originally Posted by ETbyrne View Post
PHP Code:
if(!empty($route[preg_replace('/^(\/)/','',$url)])) 
Does not produce an E_NOTICE error.
Like isset, calling empty will not raise any NOTICE if the variable is not found.


Quote:
Originally Posted by ETbyrne View Post
So, any thoughts on the the framework from a application developers perspective? Like, how controllers work, how you access views, ect...
I've only had a very brief look at the framework, mostly as a result of Kalle's post. Your method of gathering the request variables and pushing them through to a controller is odd (constructing a string for the arguments and evaling it.

Also, perhaps I'm missing something, but the only way to have any form of dynamic routes is you use what you call plugins? For example, how could one have "user/1" refer to (user.php) controller::index(1) or something more abstracted like "img/abc.jpg" refer to (images.php) controller::stream('abc', 'jpg')? The Routes documentation doesn't make any mention of any more basic than straight substitution (mypage => mycontroller/func/argument).

Your requirement of loading MySQLi should be disabled by default. Not every application wants to always have access to a database and even if they did, not necessarily MySQL via the MySQLi extension.

Helpers: I'd like to see these namespaced (class-based... we can use "real" namespaces somewhere in the future). For example, you have the functions base_url, page_url, model_url and redirect; why not have these as url::base, url::page, url::model and url::redirect? The same can be said for cookie::set and cookie::delete (no cookie::get?).

You use short PHP tags in places, please go through and replace them will their full alternatives. You can't expect short_tags to be turned on by default, nor for people to turn them on just to support your framework.

Models: accessible by the URL? I'm not sure this should be the case, or even if it is they should always be routed through a router.

I think your whole section of index.php under "Detect Illegal Characters in URL" could do with some re-working. How you construct the regular expression doesn't result in what I think you think it does (confused yet?).

That's all, after a very quick look. I do look forward to having a really good delve into the whole framework soon though.
Salathe is offline  
Reply With Quote
Old 03-31-2009, 07:22 PM   #27 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Quote:
Like isset, calling empty will not raise any NOTICE if the variable is not found.
Which is exactly what I want it to do, not raise a notice.

Quote:
Also, perhaps I'm missing something, but the only way to have any form of dynamic routes is you use what you call plugins? For example, how could one have "user/1" refer to (user.php) controller::index(1) or something more abstracted like "img/abc.jpg" refer to (images.php) controller::stream('abc', 'jpg')? The Routes documentation doesn't make any mention of any more basic than straight substitution (mypage => mycontroller/func/argument).
At the moment only static routes are supported. I am planning on adding dynamic route support in the near future, preferably before the first BETA release. For the time being I'm just using Mod_Rewrite.

A dynamic route in the future might look like this:

PHP Code:
$route['mypage/([0-9]+)'] = 'controller/function/arg1/$1'
Quote:
Helpers: I'd like to see these namespaced (class-based... we can use "real" namespaces somewhere in the future). For example, you have the functions base_url, page_url, model_url and redirect; why not have these as url::base, url::page, url::model and url::redirect? The same can be said for cookie::set and cookie::delete (no cookie::get?).
Good idea. Probably should, and will, be done. A cookie::get() function is not necessary because you can use the built in $this->dingo->cookie() function.

Quote:
Models: accessible by the URL? I'm not sure this should be the case, or even if it is they should always be routed through a router.
One of my big pet peeves with other frameworks was the fact that you had to load models from a controller. To me that kinda defeated the whole purpose of having a model in the first place. In Dingo controllers display pages and models make changes to the database/filesystem/whatever.

Separating the models from the controllers gives your URL scheme a lot more freedom. For example: let's say you have a page users/edit/[num] to edit a user. You can have the form for that page submit to the model index.php?model=users/edit/[num], instead of having to create another controller with a different URL like users/edit2/[num] to manipulate the database.

Confusing?

Quote:
I think your whole section of index.php under "Detect Illegal Characters in URL" could do with some re-working. How you construct the regular expression doesn't result in what I think you think it does (confused yet?).
I'll have to revisit that, all I remember is it being a total pain in the you know what!

Btw, I'm considering restructuring the bootstrap for better modularity. If that makes any sense.

Thanks for all the detailed feedback everyone!
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 03-31-2009, 08:21 PM   #28 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by ETbyrne View Post
Confusing?
Yes. What about things which shouldn't be in the model but might be necessary when invoking an editing page? Authorising the current user, validation of the supplied input data, routing different scenarios through to different views, etc.. Is that all to be done in the model?

Very good to hear that you're planning on allowing more dynamic routing! cookie::get is only a helper, it can call Dingo::cookie if you really want it to. Without it, the API just seems unbalanced.
Salathe is offline  
Reply With Quote
Old 03-31-2009, 08:31 PM   #29 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Quote:
Yes. What about things which shouldn't be in the model but might be necessary when invoking an editing page? Authorising the current user, validation of the supplied input data, routing different scenarios through to different views, etc.. Is that all to be done in the model?
I usually use auto-loaded helpers for repetitious tasks like authorizing the current user, validations, ect...

Quote:
Very good to hear that you're planning on allowing more dynamic routing! cookie::get is only a helper, it can call Dingo::cookie if you really want it to. Without it, the API just seems unbalanced.
I suppose I could, it can't really hurt.

I was just looking at namespaces in PHP 5.3 and was very, very, very impressed! I think I'll be restructuring the framework to use them sometime soon! I want to change it so that libraries use namespaces instead of loading a class into the $this->dingo object. For example running a MySQLi query would look like this:

Code:
dingo\mysqli->query($sql);
Instead of

PHP Code:
$this->dingo->mysqli->query($sql); 
I think that's right... Btw I used the CODE BBcode block for the first piece of code because the PHP one doesn't like my backslash...
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 04-01-2009, 01:25 AM   #30 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

I just uploaded a new version to the site with a few fixes, most of which where outlined by Kalle.
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 04-01-2009, 11:25 AM   #31 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Any chance of using SVN/Git so we can just suck down any changes without having to re-download a zip file from your site? It'll help us (and you, perhaps) keep up-to-date with what exactly changed and when.
Salathe is offline  
Reply With Quote
Old 04-01-2009, 12:20 PM   #32 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

I'm in favor of that (SVN that is, don't know Git), xp-dev have free private svn repos you can use.

http://xp-dev.com

Not had chance to properly look at this yet, been too busy , however my initial concerns have been mentioned (use of eval being one of the primary ones).
I'll research further before I make any recommendations etc.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 04-01-2009, 03:35 PM   #33 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

Quote:
however my initial concerns have been mentioned (use of eval being one of the primary ones).
I removed eval() completely from the framework with the latest update. I'll think about putting up an SVN...
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 04-01-2009, 04:51 PM   #34 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

I might setup a code repository on Github later today...
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 04-02-2009, 09:57 AM   #35 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

or you can be old school like us at php.net and use CVS :)
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Old 04-02-2009, 10:15 PM   #36 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

I've been in the process of updating my local server to PHP 5.3 so I can start restructuring Dingo to use namespaces. I'm also working on replacing PATH_INFO with REQUEST_URI or PHP_SELF.
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 04-03-2009, 11:34 AM   #37 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Quote:
or you can be old school like us at php.net and use CVS :)
Noooooo!!!! xD
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 04-05-2009, 02:53 PM   #38 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

I've gotten a TON of work done on Dingo, enough to warrant changing it from version 0.1.2 to 0.1.3! I have the new version uploaded to the site. Here's a short list of what's changed:

Functions
They take a lot less writing. For example instead of doing this:
PHP Code:
$this->dingo->mysqli->query(); 
You can do this:
PHP Code:
$this->mysqli->query(); 
Organization
Helpers and libraries are now loaded from the "load" class:
PHP Code:
$this->load->helper();
$this->load->library(); 
Input data can now be accessed through the "input" class:
PHP Code:
$this->input->post();
$this->input->get();
$this->input->cookie();
$this->input->request(); 
URL Helper
The URL Helper functions are now placed in a class and can be accessed like so:
PHP Code:
url::base();
url::page();
url::model();
url::plugin_page();
url::plugin_model();
url::set_cookie();
url::delete_cookie();
url::redirect(); 
Routes
Routes can now use regular expressions:
PHP Code:
$route['one/([a-zA-Z]+)/([0-9]+)'] = 'query/$1/$2'
I'm in the process of updating the documentation on the site for the new version.
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 04-05-2009, 07:13 PM   #39 (permalink)
how quixotic are you?
 
ETbyrne's Avatar
 
Join Date: Dec 2007
Location: Lapeer, MI
Posts: 445
Thanks: 37
ETbyrne is on a distinguished road
Default

I just uploaded a new one that fixed a couple bugs causing plugins not to work. If you downloaded the one I uploaded earlier today then download the new one and just replace index.php and the URL Helper with the new ones.

Btw happy Palm Sunday!
__________________
Dingo Web Systems > http://www.dingocode.com
My Website > http://www.evanbot.com
ETbyrne is offline  
Reply With Quote
Old 04-06-2009, 06:46 PM   #40 (permalink)
The Contributor
 
WebSavvy's Avatar
 
Join Date: Mar 2009
Location: Springfield, IL USA
Posts: 75
Thanks: 3
WebSavvy is on a distinguished road
Default

Looks like you've put an awful lot of work into this. I wish you great success with it.

Happy Palm Sunday to you, too.
WebSavvy is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for partner(s) for open source framework Scottymeuk General 4 02-06-2009 12:05 AM


All times are GMT. The time now is 04:40 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design