We got nominated! Help us out and vote for GitHub as Best Bootstrapped Startup of 2008. (You can vote once a day.) [ hide ]

public
Description: A simple php class that can be used to build an entire web application framework
Homepage: http://72squared.com/scratchpad/
Clone URL: git://github.com/72squared/grok-php.git
adding a __tostring magic method to grok container.
auto append the .php suffix if it doesn't exist.
John Loehrer (author)
Mon Aug 04 08:57:37 -0700 2008
commit  6f5aa33590c6fd29225b5aef4e0aad6e803448fb
tree    9becead482969c9ba52f7136aaabc9f7535d34b5
parent  b28c04bdfa3e23cd40f5641f1a2c6bd01fe775ab
...
2
3
4
5
 
6
7
8
...
10
11
12
13
14
15
16
17
 
18
19
20
 
21
22
...
2
3
4
 
5
6
7
8
...
10
11
12
 
 
 
13
 
14
15
16
 
17
18
19
0
@@ -2,7 +2,7 @@
0
 // an example of a CLI app.
0
 
0
 //find the current dir
0
-$cwd = dirname(__FILE__);
0
+$cwd = dirname(__FILE__) . DIRECTORY_SEPARATOR;
0
 
0
 // make sure we are running from cli.
0
 if( ! is_resource( STDIN ) ){
0
@@ -10,13 +10,10 @@ if( ! is_resource( STDIN ) ){
0
     die('<h1>Please run this from CLI.</h1><h2>Does not work in browser.</h2>');
0
 }
0
 
0
-// set the current working directory.
0
-chdir( dirname(__FILE__) );
0
-
0
 // include grok
0
-include 'grok.php';
0
+include $cwd . 'grok.php';
0
 
0
 // kick it off, reading from STDIN
0
-Grok::instance(array('STDIN'=>STDIN) )->dispatch($cwd . '/app/main.php');
0
+Grok::instance(array('STDIN'=>STDIN) )->dispatch($cwd . 'app/main.php');
0
 
0
 // EOF
...
79
80
81
82
 
83
84
85
86
87
88
89
 
90
91
92
93
94
95
96
 
97
98
99
100
101
102
103
 
104
105
 
 
 
 
 
 
 
106
107
108
...
141
142
143
 
 
 
144
145
146
...
79
80
81
 
82
83
84
85
86
87
88
 
89
90
91
92
93
94
95
 
96
97
98
99
100
101
102
 
103
104
105
106
107
108
109
110
111
112
113
114
115
...
148
149
150
151
152
153
154
155
156
0
@@ -79,30 +79,37 @@ class Grok_Container implements Iterator {
0
    /**
0
     * @see http://www.php.net/oop5.magic
0
     */
0
- private function __set( $k, $v ){
0
+ protected function __set( $k, $v ){
0
         return $this->__data[ $k ] = $v;
0
     }
0
     
0
    /**
0
     * @see http://www.php.net/oop5.magic
0
     */
0
- private function __get( $k ){
0
+ protected function __get( $k ){
0
         return isset( $this->__data[ $k ] ) ? $this->__data[ $k ] : NULL;
0
     }
0
     
0
    /**
0
     * @see http://www.php.net/oop5.magic
0
     */
0
- private function __unset( $k ){
0
+ protected function __unset( $k ){
0
         unset( $this->__data[ $k ] );
0
     }
0
     
0
    /**
0
     * @see http://www.php.net/oop5.magic
0
     */
0
- private function __isset( $k ){
0
+ protected function __isset( $k ){
0
         return isset( $this->__data[ $k ] ) ? TRUE : FALSE;
0
     }
0
+
0
+ public function __toString(){
0
+ $out = get_class( $this ) . ' { ';
0
+ foreach( $this as $k=>$v) $out .= $k . ': ' . $v . ', ';
0
+ $out = trim($out, ', ');
0
+ return $out . " }";
0
+ }
0
 }
0
  
0
 /**
0
@@ -141,6 +148,9 @@ class Grok extends Grok_Container {
0
         // make sure we are using the correct filepath delimiter here
0
         if( '/' != DIRECTORY_SEPARATOR ) $__file = str_replace('/', DIRECTORY_SEPARATOR, $__file );
0
         
0
+ // add a php extension if one can't be found.
0
+ if( substr($__file, -4) != '.php' ) $__file .= '.php';
0
+
0
         // blow up if we can't find the path to this file.
0
         if( ! file_exists( $__file ) ) throw $this->exception('invalid-dispatch: ' . $__file );
0
         

Comments

    No one has commented yet.