Andy-H Posted March 2, 2012 Share Posted March 2, 2012 Anyone got it up and running yet? http://php.net/releases/5_4_0.php Looking through the notes the features I'm happiest about are the <?= $var; ?> being enabled regardless of short tag open, but maybe I'm just lazy? lol And the new short array syntax: foreach( [ 1, 2, 3] AS $val ) {} especially as earlier today I was working on a js-intensive application and started writing a PHP script straight afterwards and wrote <?php array = array('test', 'test2'); for ( var i in array ) // lol Also the class member access on instantiation could be useful for lazy programmers like me lol Quote Link to comment Share on other sites More sharing options...
Andy-H Posted March 2, 2012 Author Share Posted March 2, 2012 http://gonzalo123.wordpress.com/2011/11/28/playing-with-the-new-php5-4-features/ Didn't notice the callable typehint =P Quote Link to comment Share on other sites More sharing options...
kicken Posted March 2, 2012 Share Posted March 2, 2012 I was messing with the beta's a bit. I haven't tried running any of my existing stuff on it, might give it a try over the weekend on my laptop. Not sure how soon it'll be before I take advantage of any of the features. Our prod stuff probably wont update for a long time. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted March 2, 2012 Author Share Posted March 2, 2012 Yeh, our work servers probably won't either, might install it locally and have a mess around tho. Quote Link to comment Share on other sites More sharing options...
Philip Posted March 2, 2012 Share Posted March 2, 2012 The only one I'm remotely excited about is the shortened array syntax. Coming from a lot of JS work, this is nice. Quote Link to comment Share on other sites More sharing options...
kicken Posted March 3, 2012 Share Posted March 3, 2012 I like the short tag echo as i use that in my templates, and now I won't need the str_replace then eval hack if short tags is disabled. The short array syntax and array-dereferencing will both be nice (eg $first=explode('.', $var)[0]); Also being able to call a member function directly will be nice, I've had a few cases where I wanted to do that, mainly with the DateTime object, eg: $date = (new DateTime($row['date'], $usersTimeZone))->format('m/d/Y H:i'); It's just a shame that I probably wont really get to use any of it for a year or more. Quote Link to comment Share on other sites More sharing options...
joe92 Posted March 3, 2012 Share Posted March 3, 2012 The only one I'm remotely excited about is the shortened array syntax. Coming from a lot of JS work, this is nice. Ditto. Hopefully JavaScript will do the same in reverse and make a few of its language constructs more like php... Ah, one can dream. Quote Link to comment Share on other sites More sharing options...
trq Posted March 3, 2012 Share Posted March 3, 2012 Iv'e been building a framework around 5.4 for the last 4 months or so (link in my signature). Besides the stuff that kicken mentioned there probably not a great deal more in it. I have used traits a few times but it was a bit forced and will likely be removed eventually. I'm yet to really find a strong use case for them. The built in web server has come in handy a few times as I only built 5.4's cli to start with. Quote Link to comment Share on other sites More sharing options...
Andy-H Posted March 3, 2012 Author Share Posted March 3, 2012 Framework looks really good, although I don't really understand the need for events in a blocking environment? (I'm sure this is just down to a lack of experience/knowledge on my part, I just don't get it because php is parsed left-right top-bottom) I know you said in your blog that you will be able to register an option to validate by regex, will this also be capable of implementing filter_var with various flags? (such as validate email) Quote Link to comment Share on other sites More sharing options...
trq Posted March 3, 2012 Share Posted March 3, 2012 A bit OT, but what the heck... Framework looks really good, although I don't really understand the need for events in a blocking environment? (I'm sure this is just down to a lack of experience/knowledge on my part, I just don't get it because php is parsed left-right top-bottom) The events are just a fancy name for "hooks" really. It simply allows you to inject code into certain points in the bootstrap process. You could of course also use this same functionality within your application to make it easily extendable. I know you said in your blog that you will be able to register an option to validate by regex, will this also be capable of implementing filter_var with various flags? (such as validate email) A type validator (assuming your talking about the opt component) can be any function that returns a bool. To use your example: $ops = $this->setOptions([ 'user_email' => (new Option()) ->addTypeValidator('email', function($value) { return filter_var($value, FILTER_VALIDATE_EMAIL)); })->type('email') ], $options); Quote Link to comment Share on other sites More sharing options...
Adam Posted March 3, 2012 Share Posted March 3, 2012 Yeh, our work servers probably won't either, might install it locally and have a mess around tho. I doubt you will see many companies upgrading before at least 5.4.1, when they will undoubtedly fix a bunch of issues with it. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted March 3, 2012 Share Posted March 3, 2012 does it have object literals? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted March 4, 2012 Author Share Posted March 4, 2012 I don't really know what bootstrap is, I mean, I'm assuming it's a design pattern, all I could figure from the documents about it is that it's a simple process which delegates tasks to run more complicated code? I'm guessing hooks is pretty self-explanatory, you hook code into a main processing script to act upon certain variables? From writing that I figure a hook is a kind of bootstrap? Will you be able to create re-usable options? Such as checking if the post array has a key containing "email" and running that through filter validate email? I think that would be quite good, then maybe an opt-out? Like this post key contains "email" but I don't want to validate it as an email, kind of code automation. Quote Link to comment Share on other sites More sharing options...
kicken Posted March 4, 2012 Share Posted March 4, 2012 I don't really know what bootstrap is Bootstrap is refers to the startup process. It encompasses everything you need to do just to get a system up and running, before you actually start processing anything. This is things like including any necessary classes, setting up your database connection, starting up a session, etc. Quote Link to comment Share on other sites More sharing options...
trq Posted March 5, 2012 Share Posted March 5, 2012 Will you be able to create re-usable options? Such as checking if the post array has a key containing "email" and running that through filter validate email? I think that would be quite good, then maybe an opt-out? Like this post key contains "email" but I don't want to validate it as an email, kind of code automation. That sort of validation is at a much higher level to where the framework currently is. At the moment, I'm just focused on getting the very low level functionality in place. The Opt component (which is what I assume your looking at) is not designed to validated user input per say. It is designed to validate function arguments where type hinting is not available. Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted March 5, 2012 Share Posted March 5, 2012 If you want to use xDebug with php 5.4.0 - I have compiled the windows dll myself (with only 1 issue: max_exec_time isn't modified so have to modify in php.ini - nothing major). Or I can outline steps to compile xdebug yourself. (fairly lengthy, from tools download to using the dll in netbeans can take up to an hour depending on network speed.) Quote Link to comment Share on other sites More sharing options...
trq Posted March 6, 2012 Share Posted March 6, 2012 If you want to use xDebug with php 5.4.0 - I have compiled the windows dll myself (with only 1 issue: max_exec_time isn't modified so have to modify in php.ini - nothing major). Or I can outline steps to compile xdebug yourself. (fairly lengthy, from tools download to using the dll in netbeans can take up to an hour depending on network speed.) Lucky for me I use a nice up to date Linux distro that already has php5.4 and all of it's extensions available (has done since the alpha releases). Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted March 6, 2012 Share Posted March 6, 2012 Even xdebug? Since he hasn't compiled 2.2 yet.. Quote Link to comment Share on other sites More sharing options...
trq Posted March 7, 2012 Share Posted March 7, 2012 Actually, Xdebug doesn't look like it will build against 5.4 yet. I could have sworn I had already installed it. Quote Link to comment Share on other sites More sharing options...
ChemicalBliss Posted March 8, 2012 Share Posted March 8, 2012 Ohh it can . I'm using it as we speak . Apache 2.4.1 PHP5.4.0 (release) xDebug 2.2 Dev NetBeans 7.2 Dev Quote Link to comment Share on other sites More sharing options...
trq Posted March 8, 2012 Share Posted March 8, 2012 Ohh it can . I mean't via my package manager. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.