archive-com.com » COM » S » STUARTHERBERT.COM

Total: 477

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Stuart on PHP - » Competitions
    be sure that the DLL is compatible with your copy of SQL Server Back in the SQL Server 2000 days you could also get it by installing the SQL Server Client Tools onto your web server always a good idea very handy being able to fire up SQL Server Management client to diagnose database connection issues when working in firewalled DMZ environments If memory serves it s been 18 months since I did this for a living the need for ntwdblib dll will finally go away when PHP has a modern extension that uses the SQLDMO or later API The MSSQL extension uses TDS to talk to SQL Server currently Unfortunately TDS was designed for Sybase and lacks support for useful features in SQL Server 2000 and beyond like unicode Of course there s a downside switching from TDS will make it almost impossible to use Linux webservers against an SQL Server back office setup The quick fix is to edit php ini and disable those extensions for now With that done http localhost phpinfo php now works Woohoo Test case satisfied Improving On PHP Performance One of the best ways to boost the performance of your PHP scripts for free is to download and use Zend Optimizer If you haven t heard of it before Zend Optimizer analyses your PHP code when it is loaded into the PHP scripting engine and rewrites the bytecode to be more efficient Zend have made it available as a free download for several years but now it s also available as part of the larger Zend Server bundle where it is known as Zend Optimizer Zend Server s copy of PHP also comes with APC the bytecode cache that will be bundled by default with a future version of PHP I ve lost track of whether that will be PHP 5 3 or PHP 6 which also boosts the performance of your code This is something you have to download separately if you use the PHP installer from www php net And it s also worth looking at Zend Server for its simple web based control panel to manage your PHP configuration and if you buy a license for the product for its ability to monitor your PHP scripts to see what needs your attention I was very pleased with how easy it was to install and configure Zend Server Like the community PHP installer it doesn t seem to support anything other than the default web site which is a serious oversight for use in larger organisations but otherwise its ease of use is exactly what your average Windows PHP dev would appreciate Interestingly when it comes to databases Zend Server doesn t include the PDO extension for SQL Server I had a very quick go at taking PHP net s build of pdo mssql and installing it into Zend Server s build of PHP but unfortunately Zend Server reported that the extension failed to load The problem is that PHP net s release of PHP and extensions is built with thread safety on but Zend Server s release of PHP is built with thread safety off It s not for me to say which one is right but it does mean that the two different releases appear to be binary incompatible And that is something that can t be good for the PHP community on Windows overall PS make sure you un install the community version of PHP for Windows before installing Zend Server If you use Command Prompt to run Zend Server s php exe it goes and loads the php ini file from the community version of PHP first which created some interesting problems whilst preparing this article Basically if you manage to screw up PHP so it can t run the Zend Server control panel stops working precisely because it is written in PHP A bit of an egg chicken situation there Choosing A Database Server Most web based applications today use a RDBMS to store and retrieve their data Microsoft have made a baby version of their heavyweight SQL Server product available for developers to work with Microsoft has made it easy to get SQL Server Express through their Web Platform Installer They currently have a beta 2 0 release out that also includes bundled PHP However I can t recommend this approach at the moment because of the licensing terms which state that this is pre release software that you re not allowed to use in a live operating environment and that your rights to use the software expire at the end of June 2009 or whenever a commercial version of the platform installer is released whichever happens first I don t have a problem with closed source software but I do object to software with expiry dates I accept that I m in a minority on this SQL Server Express is a fat lady 218 MB in size Definitely not something I can download over mobile broadband whilst traveling to and from the office By contrast MySQL RPMs for RedHat Enterprise Linux 5 weighs in at a positively svelte 28 2 MB almost a tenth of the size And it comes with more features But as I m actually quite a fan of SQL Server I m going to add it to my dev environment The list of download options might be too cryptic for some developers For 32 bit systems download the x86 file For 64 bit systems download the x64 file Perhaps Microsoft might want to put suitable descriptions on this list for folks who aren t sure which file is right for them Oh and don t forget to download the dependencies listed earlier up the page they re not present on a fully updated Windows Server 2008 install I swear it s just as bad as using a RedHat box Choosing A Version Control System If you don t use one already you should Version control systems are an essential part of any development environment even for one man hobby projects such as this one My VCS of choice is git Subversion runs well on Windows and has for years but I m very mobile and absolutely need the ability to make commits whether or not I have internet access at the time Walk in my shoes for a week and you ll find the idea that we re now always connected somewhat laughable I don t make anywhere near full use of git s many excellent features like many folks I m waiting for the books on git to appear later this year There s a port of git for Windows from the msysgit project on Google Code I haven t used it before so it ll be interesting to discover how well it works Choosing A PHP IDE I ve used phpEclipse on Windows for PHP development for several years but the guys at worked convinced me to switch to using the Netbeans nightly builds instead The demise of Sun earlier this week has cast a shadow over whether or not Netbeans has a future Oracle in the past has not been a supporter of Netbeans but until someone pulls the plug it s my IDE of choice As with git I ve never used it on Windows so it ll be interesting to see how well it works Using Netbeans also means downloading Java which you need to do before you can install the PHP bundle of Netbeans Downloading Java for Windows is a two step process you download a small installer first and when you run the installer it goes off and downloads the complete Java standard edition as a second step I ve never understood why Sun do this perhaps it s their way of ensuring that you always have the latest version of Java available when you actually do the install Answers on a postcard please Netbeans currently only supports the excellent xdebug extension for PHP for single step debugging It doesn t support Zend Server s own zend debugger extension Does anything other than Zend Studio I had no luck at all getting any of the xdebug DLLs working with Zend Server both the thread safe and non thread safe versions cause Zend Server s copy of PHP to crash I haven t actually tried it but I expect that the xdebug DLL works absolutely fine with the PHP for Windows from php net Hrm it s been a tricky decision but for now I ve decided to stick with Zend Server because I want to evaluate how useful its built in monitoring is If the lack of xdebug becomes a problem I can always setup a second website under IIS w PHP from PHP net and just switch between the two Completing The Development Environment Visual Studio To finish my development environment I need something for building debugging NET code Part of my application needs to be built in NET Again thanks to the folks from Microsoft who attended the PHP UK Conference 2009 I have a 1 year evaluation license for Visual Studio 2008 Standard Edition From the install screens I m led to believe that updates for Visual Studio are downloaded using Windows Update But Windows Update states that there are no updates available I m having a bit of trouble believing that The Development Environment Recap With the development environment now up and running I thought it would be useful to recap on what the full environment looks like Second generation MacBook Pro using a Samsung PB22 J 256GB SSD Microsoft Windows Server 2008 running inside VMWare Fusion Zend Server running on a free trial license Mozilla Firefox Firebug FirePHP with Internet Explorer consigned to the trash can git for Windows from the mysgit project on Google Code git repository replicated up to github Netbeans nightly build using the PHP bundle Visual Studio 2008 Standard Edition Note that I have chosen not to spend money on anti virus software for Windows because the VM will be used for a one off project and then destroyed If Windows was your regular dev platform you d need to invest in anti virus and anti spyware software and pay a regular subscription in order to keep it up to date With downloaded installers and temporary files deleted the overall size of the Windows Server 2008 virtual machine now stands at 10 54GB according to OS X and 11 3 GB according to Windows Server 2008 I m left with only 4GB of free space under OS X and will be spending the evening looking for ways to free up a bit more space How do I feel about the development environment A little disappointed if truth be told Under Windows I m largely stuck with building the development environment from the pre built components other people have made for me That s fine until combining those components reveals compatibility and or quality problems It s worth pointing out how useful Twitter has been during this work I ve had no less than three folks from Zend responding to my tweets including their CEO and the Zend Server product manager I m not a Zend customer nor am I known to be a Zend advocate At work we spend more with organisations like VMWare and Netsuite than we could ever need to spend with Zend and yet their support simply doesn t match up to how responsive Zend has been Next Steps With the development environment built it s time to turn my attention to the app I m going to build Before I write any code I need to sketch out a design for the app and probably do some R D on the components that will be completely new to me I m unlikely to write any PHP code for some time yet Be the first to leave a comment First Challenge Development Environment Posted by Stuart Herbert on April 20th 2009 in European WinPHP Challenge 2009 This is one of a series of blog posts about my experience competing in the European WinPHP Challenge 2009 Sponsored by iBuildings Microsoft and Leaseweb competitors are asked to build a PHP app for Windows Server 2008 and IIS 7 to showcase the FAST in FastCGI The winner gets travel and tickets to Microsoft MIX 2010 in Las Vagas in March My entry is Give It A REST a SOAP REST gateway When it comes to software development I m old fashioned I m a firm believer that you should develop and test on the platform that you re going to ship your code for And that means getting Windows Server 2008 installed somewhere convenient My primary test case for this step is to be able to publish the output of phpinfo at http localhost phpinfo php via FastCGI on IIS 7 As it has been over 18 months since I last used Windows Server I hope my experiences prove helpful for anyone else going through this for the first time Getting Windows Server 2008 Installed Installing IIS 7 Downloading PHP 5 2 9 for Windows Choosing A PHP Install Creating The Phpinfo File Testing The Phpinfo File Next Steps Getting Windows Server 2008 Installed Convenient for me means VMWare Fusion running on my MacBook Pro My laptop is my main machine and I m too mobile to make software development via Remote Desktop practical Thankfully I have a Windows Server 2008 license which the folks at Microsoft dropped into my hands at the recent PHP UK 2009 Conference But what I am short of is disk space Last week I replaced my MacBook Pro s hard drive with one of those very nice Samsung SSD s Actually nice doesn t remotely do it justice but what you get in performance you lose in capacity It took three attempts to get Windows Server 2008 up and running under VMWare Fusion First attempt failed because the internal DVD drive couldn t read the install media I suspect the DVD drive is faulty although the install media is somewhat scratched fresh out of the packaging Second attempt failed because VMWare Fusion crashed I ve never seen Fusion crash before so that was entertaining Third time lucky up and running and waiting for the inevitable critical updates to download and install And then the next batch It s an unavoidable process no matter which OS you choose to be fair but it would be less wearying if Microsoft batched up the fixes into service packs much more frequently in order to save time and reboots This blog post is particularly verbose because I have plenty of time waiting for things like Windows updates and other downloads Future posts will be much shorter So a minimal installation of Windows Server 2008 has taken up 9 44 GB of space so far leaving me with just 6 GB of space left on my computer With IIS 7 Visual Studio and SQL Server still to be installed plus a PHP IDE I can see that this is going to be a problem By contrast my Ubuntu desktop install all in weighs in at only 7 7 GB of used disk space I might just have to archive my CentOS server test VM for the duration Installing IIS 7 Next step get IIS 7 installed Hrm it doesn t appear on the list of features that Server Manager knows about But it doesn t appear to be installed yet either Where the frack is it Answer Windows Server 2008 uses the concept of roles Pop into the roles section of Server Manager and you ll find IIS 7 there Click through to the Next page to go through the Web Server options in detail and where is FastCGI There s no mention of it at all It seems to be bundled with the CGI option Perhaps a future update from Microsoft could update the description to mention that Folks used to a Linux platform are also used to having different web server modules for CGI and FastCGI features Downloading PHP 5 2 9 For Windows Before we can configure IIS 7 FastCGI we need a copy of PHP for Windows I thought that it might save time to simply download Zend Server CE for Windows and see how that went Unfortunately when I checked this evening the Zend Server downloads page didn t list any downloadable packages for Windows so that wasn t an option Update the downloads work now Many thanks Zend Not a problem thinks I I ll just download the pre built PHP for Windows binaries from www php net Until now I ve resisted talking about how annoying the infamous User Account Control UAC feature of Windows Vista Server 2008 is I don t want these blog posts to be a review of Windows Server But as annoying as it quickly becomes UAC is nowhere near as annoying as the Trusted Sites feature of IE Especially because this feature stops you from downloading the PHP for Windows binaries from www php net It doesn t ask me whether I would like to allow the download It just refuses to download the ZIP file that I have clicked on presumably because www php net actually sends back a redirect to a local mirror I couldn t quickly spot a way to disable the Trusted Sites feature of IE the controls are disabled in IE s Options dialog box Not a problem thinks I I ll just download Firefox and avoid using IE Guess what The Trusted Sites feature of IE stops you downloading Firefox too again presumably because the download link on Mozilla s page sends back a redirect to another server Mozilla might want to do something about that they must be missing out here The way around it is to go into Security Manager and down on the right hand side of the initial page is a

    Original URL path: http://blog.stuartherbert.com/php/category/competitions/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » I Have Two PHP Developer Vacancies To Fill
    co author of the Official Zend Certification Study Guide for PHP 4 and a regular speaker at conferences and user groups since 2004 When he s not designing software Stuart loves to explore the world through a camera lens spend time with his beloved guitars and continue his study to T ai Chi Chu an Taijiquan No Comments AntonioCS says April 29th 2009 at 2 30 pm one nice bonus is that we use Linux for our desktops not Windows I really don t get this one What s the big problem of using windows In the company I worked for they didn t really cared what we used Some had windows others had linux PHP will mostly behave exactly in windows as it does in linux As long as you have a nice IDE and all the stuff you need to run you php apps websites don t really see the big victory of either using windows or linux Stuart Herbert says April 29th 2009 at 2 59 pm I really don t know how to answer that one From an engineering point of view I m old school you should create your apps on the platform they will be deployed on Mostly doesn t cut it at this level From an enjoyment point of view I enjoy working with folks who are as passionate about their tech as I am and these folks typically enjoy using Linux desktops and don t enjoy using Windows AntonioCS says April 29th 2009 at 2 30 pm one nice bonus is that we use Linux for our desktops not Windows I really don t get this one What s the big problem of using windows In the company I worked for they didn t really cared what we used Some had windows others had linux PHP will mostly behave exactly in windows as it does in linux As long as you have a nice IDE and all the stuff you need to run you php apps websites don t really see the big victory of either using windows or linux Stuart Herbert says April 29th 2009 at 2 59 pm I really don t know how to answer that one From an engineering point of view I m old school you should create your apps on the platform they will be deployed on Mostly doesn t cut it at this level From an enjoyment point of view I enjoy working with folks who are as passionate about their tech as I am and these folks typically enjoy using Linux desktops and don t enjoy using Windows Mikko says April 29th 2009 at 5 18 pm AntonioCS case in sensitivity is where the problems often arise not that much of the PHP itself Mikko says April 29th 2009 at 5 18 pm AntonioCS case in sensitivity is where the problems often arise not that much of the PHP itself Latest Photos Categories phpnw 1 Beginner 2 Intermediate 3 Advanced Brighton PHP Conferences Opinion

    Original URL path: http://blog.stuartherbert.com/php/2009/04/29/i-have-two-php-developer-vacancies-to-fill/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » Finding Ada
    since 2004 When he s not designing software Stuart loves to explore the world through a camera lens spend time with his beloved guitars and continue his study to T ai Chi Chu an Taijiquan No Comments Elizabeth M Smith says March 24th 2009 at 6 34 pm Unfortunately most of the problems are from the male dominated environments and behavioral issues not in the technical tools or practices that are used Women are a lot more apt to simply switch careers or not choose a career where they have to put up with pardon the language jackass guys Elizabeth M Smith says March 24th 2009 at 6 34 pm Unfortunately most of the problems are from the male dominated environments and behavioral issues not in the technical tools or practices that are used Women are a lot more apt to simply switch careers or not choose a career where they have to put up with pardon the language jackass guys Juliette says March 25th 2009 at 9 26 am Agreed It s the colleagues behaviour that turns women away constantly battling against it is tiring and depressing Juliette says March 25th 2009 at 9 26 am Agreed It s the colleagues behaviour that turns women away constantly battling against it is tiring and depressing Jennifer says April 13th 2009 at 6 06 pm I haven t really had any problems with behavioral issues from male programmers and I ve had several jobs Makes me wonder where these two ladies are working that they encounter so many jackass guys and what constitutes jackassery egotism Sexual harassment I m curious because outside of college I ve experienced nothing but professionalism If anything I often feel extra welcomed somehow As for getting more women into technology fields I don t think you re going to find some lure to bring them in I think many women just aren t interested in parking in front of a computer all day they don t get fulfillment from working with a pile of machinery I doubt there s some female friendly IDE where you drag and drop kittens and rainbows instead of components and vectors that is going to magically make women interested in programming If someone is not interested in a particular career they re just not interested Jennifer says April 13th 2009 at 6 06 pm I haven t really had any problems with behavioral issues from male programmers and I ve had several jobs Makes me wonder where these two ladies are working that they encounter so many jackass guys and what constitutes jackassery egotism Sexual harassment I m curious because outside of college I ve experienced nothing but professionalism If anything I often feel extra welcomed somehow As for getting more women into technology fields I don t think you re going to find some lure to bring them in I think many women just aren t interested in parking in front of a computer all day they don t get

    Original URL path: http://blog.stuartherbert.com/php/2009/03/24/finding-ada/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » PHP UK Conference Tomorrow
    and user groups since 2004 When he s not designing software Stuart loves to explore the world through a camera lens spend time with his beloved guitars and continue his study to T ai Chi Chu an Taijiquan Comments are closed Latest Photos Categories phpnw 1 Beginner 2 Intermediate 3 Advanced Brighton PHP Conferences Opinion phix PHP In Business PSR Servers and Hosting Storyplayer Talks Toolbox Training Uncategorized Archives February 2016 January 2016 November 2015 October 2015 August 2015 March 2015 January 2014 May 2013 April 2013 March 2013 December 2012 November 2012 October 2012 September 2012 August 2012 July 2012 June 2012 May 2012 February 2012 January 2012 October 2011 September 2011 August 2011 July 2011 April 2011 March 2011 February 2011 October 2010 August 2010 July 2010 February 2010 January 2010 October 2009 September 2009 August 2009 May 2009 April 2009 March 2009 February 2009 January 2009 December 2008 November 2008 October 2008 September 2008 August 2008 June 2008 May 2008 April 2008 March 2008 January 2008 December 2007 November 2007 October 2007 July 2007 April 2007 March 2007 February 2007 January 2007 This Month February 2009 M T W T F S S Jan Mar 1 2

    Original URL path: http://blog.stuartherbert.com/php/2009/02/26/php-uk-conference-tomorrow/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » PHP In Business
    the piss out of They are years ahead of us in so many important areas and yet PHP is thriving more than ever They must have done something wrong because they sure didn t grow the market for web applications What did they do wrong The fundamental mistake the Rails designers have made and one that they still haven t groked en mass that I can see is architectural not philosophical Rails is a classic application server with all the deterministic concurrency and big iron needed here problems that stopped J2EE from squeezing out PHP at the turn of the century For many of the problems of the web the PHP execute again architecture has repeatedly been proven to be superior to the application server architecture PHP is easier for average skilled folks to deploy What s the point of creating applications if you can t figure out how to run them anywhere but your bedroom It is easier to track down and eliminate bugs in PHP applications No persistent processes mean that PHP applications are deterministic PHP code is also much simpler to work through and debug It is easier to scale applications written in PHP Folks have done it and other folks have repeated it The Rails community as yet has not It may be quicker to create applications in Rails but the operational costs once the application goes into production quickly erode that advantage If you re not in the US servers cost real money and application servers need more iron than the equivalent PHP code The Agile community likes to talk about smells so how come they don t see something like mod rails and gag on the stench of trying to mask architectural failings with such cleverness Before I make it onto Terry s Christmas card list I should state that I firmly believe that Ruby itself is a programming language that is vastly superior to PHP especially when you get away from Apache and are creating the behind the scenes plumbing required The OO in Rails continues to leave PHP for dead and OO brings many advantages to a thriving development community There are real advantages to being able to share code between both the must be real time web front end and the non real time backends and to be able to easily reuse whatever external open source libraries save you time and effort And I believe that solutions such as the Ruby gems are vastly superior to PEAR and PECL PEAR PECL should have been our CPAN or our RubyForge They deliberately chose not to be wrongly believing that CPAN was a negative feature of Perl They believed that one high quality solution would prove the superior model over time They failed to execute and the paradigm was plain wrong in the first place My prediction is that a Rails like framework but built using a PHP style mod ruby and execute again architecture would have a real chance at displacing PHP

    Original URL path: http://blog.stuartherbert.com/php/category/php-in-business/page/2/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » Toolbox
    damn ugly 1 and slow 2 that I ve had enough I program because it s something that I love doing and anything that gets in the way of that I ve no time for any more So when a work colleague introduced me to Sublime Text 2 I was in the mood to give it a go and 3 months on I haven t opened Netbeans once I ll be the first to say that Sublime Text 2 isn t for everyone It s a beta product which means there are some rough edges mostly in the plugin API I feel but it s more than stable enough for production use It has crashed a couple of times which might put some people off but I don t recall losing any work as a result File management in the project pane still needs work The regular dev builds occasionally break things It isn t a full blown IDE it s more like the spiritual successor to TextMate an editor that I never personally cared for In particular it doesn t support interactive debuggers which means no Xdebug support and there s currently no obvious way for a plugin to add that functionality in 3 Auto completion isn t anything like what you re used to The built in auto completion is based on a mix of static knowledge of languages and fuzzy matching against what you ve recently typed There s no obvious intelligence about the code you re working on nor the parameters for any method or function These are two things that many people will deeply miss 4 It isn t free but you can evaluate it for free with no time limit If you decide to buy it s substantially cheaper than both PhpStorm and Zend Studio and there s no annual subscription element to the licensing You re buying a license to support and encourage an independent developer and to show your appreciation for a very nice piece of software It s a closed source product You can t fix it yourself if it breaks and no one can pick up the reigns if it gets abandoned There seems to be just one guy behind it and if anything happened to him that d probably be the end of the product That said most of the alternatives are also closed source too Given all of that why have I switched Sublime Text 2 is very very fast Sublime Text 2 itself opens instantly Files open instantly provided they re not 100 megabyte test data files In fact everything happens instantly even inside a virtual machine running on a 3 year old laptop There are no pauses for anything to be indexed and I ve never seen CPU usage spike important for us untethered users and our suffering laptop batteries 5 And if a plugin slows things down at all Sublime Text 2 tells you which one is the culprit so that you can go and disable it I d compare the importance of the speed difference to switching from a hard disk to an SSD You don t realise how much you re waiting for your slow Java based IDE until you use something that s properly fast It renders fonts properly Droid Sans Mono and Ubuntu Mono in particular both look gorgeous and even after a long day of use my eyes don t feel like they ve been scratched on the inside by sharpened kitty claws all day long 6 True story one of my colleagues came over to ask what I was using because he thought it looked so nice from a distance When was the last time anyone ever thought that about a desktop Java app All of the searching is based on an extremely powerful fuzzy matching approach Netbeans supports regexes which can be very handy but most of the time when I m looking for something a regex is overkill but a simple string search isn t powerful enough If I ve got both a class called IpcProcess and IpcProcessID in Sublime Text 2 I can find the IpcProcessID class by searching for ipi I just have to type the shortest set of characters that uniquely matches what I m looking for It s much quicker than writing or running a regex and soon becomes second nature There s a goto anything search panel which is lightning quick Combined with the fuzzy matching approach I find this a godsend for working on multiple large code bases where there may be different classes with the same base filename or duplicate installs of a class in vendor folders or where I ve got both trunk and branches checked out for the same project It s a killer feature and one that has changed my workflow for the better especially combined with my next reason The panel s also like using Google Instant you get results as you type giving you the instant feedback you need to refine your fuzzy search There is also a goto symbol search panel and a command palette which allows you to search through the available editor commands to execute Everything can be done from the keyboard Everything can be done from the mouse too but I found that doing everything from the keyboard is both faster and doesn t break the flow of what I m working on This is something I didn t appreciate until after I d switched but it s a fantastic help to me when I ve got another developer sat next to me and we re looking at or for something together Together with the fuzzy matching it s like doing software archaeology with a JCB digger instead of a trowel It does a great job of auto detecting whether a file uses spaces or tabs for indentation and how big the tab stop is There are days when it seems like no two files I open are consistent in how the code is indented and it s rare for anyone to have tagged on a modeline to give any hints With Netbeans which has a rigid config based approach to indentation I end up playing code formatting table tennis with the original author of the file as we always seem to have different indentation settings Sublime Text 2 works out what the existing indentation approach is and just auto configures itself to match It s a great time saver 7 It strips trailing spaces from the ends of lines when I save my files This has been broken in Netbeans for years It s a small thing I know but it really annoys the crap out of me that Netbeans doesn t get this right As a bonus in Sublime Text 2 trailing spaces actually get their own setting in color schemes so you can see exactly where they are In Netbeans they re bloody invisible There s a healthy ecosystem of plugins for it over 200 plugins and counting thanks to Will Bond s Package Control package manager Will is doing a great job of making sure that each plugin is tightly focused on sorting one problem only to keep Sublime Text 2 as flexible and adaptable as possible something to keep in mind if you start writing plugins yourself Creating new plugins is very easy It took me just one evening to add and release the initial PHPUnit plugin and that included the time it took to learn both Python and the plugin API from scratch To make an update to your plugin simply push your changes to your master branch on GitHub It s as close to frictionless as you can get I can own the tool and set it up to suit my approach to programming Because extending the editor is so effortless I can automate anything that I want to suit exactly how I want it done I can create snippets intelligent macros and full blown plugins to suit and I can make them as and when some new need occurs even one off tasks In this it reminds me most of JED which was my text editor of choice back in the 90 s for exactly the same reason It s the same reason folks love Vim Btw Sublime Text 2 has a Vim mode I haven t tried it so I can t vouch for whether it s good enough to tempt Vim users over or not Like Netbeans Sublime Text 2 works on OS X Linux and Windows 8 so I can use it everywhere I used to use Netbeans I reckon it occupies a sweet spot that makes it very well suited to scripting languages and C C development albeit minus support for interactive debuggers At work some of us have taken to it and some of us haven t I m happy to recommend it to anyone who s looking for a change You can take advantage of the open ended free evaluation period and see if it suits you or not It s working for me so far and I probably spend more time using it than any other app on any of my computers If you do like Sublime Text 2 I d love for you to leave a comment below with your own reasons why Footnotes Dear Java the 1990 s called and asked for their crappy non aliased font renderer back I think Windows 3 11 is missing it terribly There was a similar parallel around 20 years At the time Emacs was by far the most fully featured editor but everyone I know chose vi because of how slow and bloaty Emacs was at the time It was so bad we used to say that Emacs stood for Eight megs and constantly swapping this was back in the days of 640K of RAM The lack of debugger support is for me the one feature that I miss every single day There is a plugin that tries to bring Komodo s auto completion to Sublime Text 2 but it stopped working for me before Christmas sadly It s like when you switch from Firefox to Chrome for the first time your laptop just gives a sigh of relief and you don t have to worry quite so much about how far away you are from the next convenient wall socket to recharge from I can easily imagine running this on a netbook or a laptop with very aggressive CPU throttling in place both places where a Java based IDE would struggle I m highly visual and find it really tiring to spend 10 12 hours a day in front of poorly rendered fonts Now if only everyone just did the right thing in the first place and used spaces instead of tab characters we wouldn t need functionality like this The keybindings are different from one platform to another and because Python isn t a platform agnostic language some plugins may not work properly on Windows at first But most plugin authors are happy to accept pull requests with portability fixes 99 comments PHPUnit Plugin For Sublime Text 2 Posted by Stuart Herbert on February 4th 2012 in Toolbox Sublime Text 2 is a new cross platform text editor that I ve recently switched to It s still in public beta but already offers better performance and battery life and a better look fonts that render properly than Java based IDEs such as Netbeans One thing it didn t have was support for PHPUnit so I ve made a plugin It s available to install via Package Control You Need A phpunit xml or phpunit xml dist File To use this plugin your project needs to contain either a phpunit xml or a phpunit xml dist file This file contains all the configuration that needs to be passed to PHPUnit The plugin searches upwards from your code and will favour a phpunit xml file over a phpunit xml dist file if it finds both If you don t have one you need to go and create one now How To Use If you have your code open in a Sublime Text 2 window right click inside the window to see what your options are Test This Class click this option to run just the unit tests for this class This option appears if the PHPUnit plugin can find your unit tests It takes the name of your class and uses the standard PSR 0 transformation to figure out what the name of your test file should be For example if your class is called Phix ProjectCommandLineLibCommandParser php the PHPUnit plugin will search for a file CommandLineParserTest php that s in a folder called Phix Project CommandLineLib Open Test Class click this option to open up your tests in Sublime Text 2 If you already have the tests open this will switch tabs to your tests Again this option only appears if the PHPUnit plugin can find your unit tests Run All Unit Tests click this option to run all the unit tests for your code This option just points PHPUnit at your phpunit xml or phpunit xml dist file If you have your tests open in a Sublime Text 2 window right click inside the window to see what your options are Run These Tests run these unit tests using the phpunit xml or phpunit xml dist file that the PHPUnit plugin has found Open Class Being Tested open the class that these tests are for in Sublime Text 2 If you already have the class open this will switch tags to your code Run All Unit Tests click this option to run all the unit tests for your code If you re someone who prefers keyboard over mouse then you ll probably want to run the PHPUnit plugin commands from Sublime Text 2 s Command Palette You get the same commands that appear on the right click menu the right commands will appear for the file that you re currently editing just as you d expect Finally you can also right click on your phpunit xml or phpunit xml dist file in the Project Sidebar and run your unit tests using that specific config file Helpful Snippets Like TextMate before it Sublime Text 2 also has a handy snippets feature where it can insert a pre crafted block of text or in our case PHP code to speed up your coding I m collecting most PHP related snippets in my Additional PHP Snippets plugin hat tip to Rob Allen for the inspiration for this but the PHPUnit plugin includes a few PHPUnit related snippets to help phpunit testcase will create a new test class for you to fill out I find this handy mostly so that I don t have to remember which class my test class has to extend phpunit test will create a new test method for you to fill out To use any snippet type its name and then press the TAB key Sublime Text 2 will insert the snippet and then you can use the TAB key to cycle through any placeholders that you need to edit If you find snippets useful please don t forget to check out my Additional PHP Snippets plugin too Feedback Contributions Welcome I d love to hear how you get on with the plugin and any ideas you might have for additional features And pull requests via GitHub are most welcome too Be the first to leave a comment Comparing ContractLib to PHP s Built In assert Posted by Stuart Herbert on January 17th 2012 in 2 Intermediate phix Toolbox One of the questions I ve been asked after yesterday s blog post about Phix s ContractLib is why not just use PHP s built in assert function I think it s a great question and the best way to answer it is to take a look at the key differences between two solutions Side By Side Comparison Feature assert ContractLib Implementation PHP extension written in C ships as standard part of PHP PHP library written in PHP Enable disable execution Partial there is an overhead when disabled but it s low Partial there is an overhead when disabled but it s higher Issues PHP4 style warning when tests fail Yes configurable No throws a ContractFailedException instead Terminate PHP script when tests fail Yes configurable Only if the ContractFailedException is never caught Quiet eval of test expression Yes configurable No not required test expressions are pure PHP code not eval strings Callback on failed test Yes configurable No unwinds the stack instead by throwing ContractFailedException Throws Exception when tests fail No but can emulate if you write your own assert callback method Yes standard behaviour Tests are pure PHP code No recommended way is to pass strings into assert to be eval d Yes Error report includes original value that failed the test No Yes Support for per test custom failure messages No Yes are required to provide one Support for Old Value storage and recall No but can emulate by hand Yes The Differences Explained The key difference is one of philosophy assert sits well with the PHP4 style of error reporting and handling whereas ContractLib is firmly in favour of the OO world s approach to reporting errors It s a personal preference but I think that PHP4 style errors have no place in code that has any desire to be robust Exceptions aren t perfect don t get me wrong but their core property of unwinding the call stack in an orderly fashion makes writing robust code much easier And they also carry a payload information about what went wrong and why which PHP s assert cannot provide to the same extent It s much quicker to debug something when there s a record of the value that failed the test For that reason alone I d always prefer something like ContractLib

    Original URL path: http://blog.stuartherbert.com/php/category/toolbox/page/2/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » Toolbox
    Now you don t even need your own web server to host it you can host it on GitHub along with the source code for your PEAR package Now if we only can get some kind of PEAR channel aggregator or similar thing to avoid having to use channel discover for every new tool we want to install Footnotes The channel name must match the regular expression a zA Z0 9 a zA Z0 9 a zA Z0 9 You might want to turn off email notifications for successful page builds because the emails can easily pile up if you make many pushes Be the first to leave a comment Real Time Graphing With Graphite Posted by Stuart Herbert on September 21st 2011 in 2 Intermediate Toolbox If you re building a web based app it s always a good idea to build some instrumentation into your app That way you can see how your app is behaving and how your users are interacting with your app over time I m sure everyone who reads my blog is familiar with Google Analytics for tracking page hits But what about what s happening inside your app Right now Do you know Graphite is one way to graph the stats that you add to your app Combine it with say statsd from Etsy and adding any stats you want is easy Read this blog post from Etsy if you want to learn more about measuring your app and how to add support for Statsd to your app Normally you ll probably be interested in looking at graphs that show your stats over a period of hours or days for trend analysis and both Graphite and Statsd are sensibly tuned for that But what if you want to see what s happening now in real time I couldn t find any clear instructions on how to do that elsewhere so here s my take on how to do it I m assuming you re already familiar with installing both Statsd and Graphite and that you ve already had both up and running successfully with their default configurations Making Statsd Forward Data In Real Time By default Etsy s Statsd collects the data sent from your apps and forwards it on to Graphite s data collector known as Carbon every 10 seconds For real time we need the data forwarded on every second To do that edit your Statsd config adding the flushInterval value graphitePort 2003 graphiteHost localhost port 8123 flushInterval 1000 A value of 1000 tells Statsd to forward data on every second Making Graphite Store Data At One Second Resolution Graphite s default sample configuration tells it to store incoming data at 60 second resolution that allows us to look at the total stats recorded minute by minute but we can t drill down to see what happens second by second To do that we have to tell Graphite to store the data on a second by second basis Edit opt graphite conf storage schemas conf and add the following clause real time priority 200 pattern stats retentions 1 34560000 This tells Graphite that we want all the data received from Statsd to be kept on a second by second basis for 400 days plenty long enough for any sort of comparison you might need to do I found that to get Graphite to start using this new storage definition I had to go and delete the existing data files by doing rm rf opt graphite storage whisper stats Getting Graphite To Draw Real Time Graphs Now all we need to do is to get Graphite showing you all the collected data in real time By default Graphite will happily plot the data onto a graph but will only generate an updated graph every 60 seconds That s perfect for an ops team looking for trends over hours but it isn t real time If you re using Memcache with Graphite you ll need to add this to your opt graphite webapp graphite local settings py file to tell Graphite to only cache data in Memcache for 1 second MEMCACHE DURATION 1 Is it worth caching the data at all at this resolution Honestly I don t know I guess that depends on how many people need to watch the data in real time or not Ideally it would be better if Graphite dynamically set the Memcache timeout based on the data stored in the particular key but for now you need to either stop using Memcache or set the cache duration to 1 second This now gives you graphs with 1 second resolution now we just need to change the Graphite web app s auto refresh feature to load a new graph every second By default it will only generate an updated graph every 60 seconds To change this we have to edit some of the app s Javascript code Open the file opt graphite webapp content js composer widgets js and locate the function toggleAutoRefresh Locate the interval variable inside that function Change its value from 60 to 1 Save the file then refresh your web browser page Et voila If you switch on auto refresh you should now be able to see your app s data being plotted second by second giving you a real time view of what your app is doing Be the first to leave a comment Steps For Building A Test VM Posted by Stuart Herbert on September 18th 2011 in phix Toolbox Using virtual machines for testing software is great I can try out anything I want and there s never any risk of trashing my main dev machine which avoids hours of lost coding time I ve been using virtual machines since the 1990 s and frankly I couldn t develop without them I ve also got a lot of experience running a private cloud of VMs for one of the UK s fastest growing tech companies but that s a topic for another day or maybe a conversation over a nice whisky at one of the upcoming conferences Right now I m using them to test phix out on multiple Linux distros before release It s a sad fact of life that all of the major distros think they can create a better PHP than the folks upstream at PHP net intended and that unfortunately means that a default install of PHP on Ubuntu can t always run the same PHP code as a default install of PHP on Fedora I found this out the hard way with an early release of phix now every release gets tested in a small but growing library of test VMs before I push it up to my public website But the best thing of all You can backup a VM normally by creating a snapshot and then rollback to your snapshot in future resetting your test environment to a known state before you test again Perfect for this weekend s task which has been documenting and double checking the steps needed to install phix on Linux dev desktops I thought it would be useful to jog my own memory when the Linux distros release their next versions to write up the steps that I do when I create a new test VM Install Linux distro from latest available ISO image Run the software upgrade tools to make sure the system is fully patched Disable SELinux if it is enabled Make sure gcc and the Linux kernel headers are installed on the system Install VMWare tools for VMWare Workstation Fusion or VirtualBox Addons for VirtualBox OSE Use Firefox to install Google Chrome Install some useful dev tools curl and git At this point I shut down the virtual machine and take a snapshot before PHP is installed That s because I need to make sure that phix s upcoming installer script does the right thing when there is no PHP If you re building your own test VMs you ll probably want to get Apache PHP and MySQL installed and your app s vhosts serving static pages before you snapshot What else would you do to a test VM to make it ready to run your tests Be the first to leave a comment PHP Components Shipping Web Pages With Your Components Posted by Stuart Herbert on August 16th 2011 in Examples phix Toolbox In my Beyond Frameworks talk I explained how a component based architecture can help answer some of the important i e expensive questions you might face when creating long lived apps that rely on a PHP framework In this series of blog posts I m going to look at how to go about creating and working with components I m now going under the bonnet of our components and looking at the different file roles that the PEAR installer expects to find when we distribute our component as a PEAR compatible package It isn t very often that a component needs to ship web pages too but should the need arise here s how to do it What Is A Web Page A web page the www file role supported by the PEAR Installer is any sort of content meant to be served up by web server software such as Apache This can be a HTML file a PHP script CSS files Javascript files images you name it Where Do Web Pages Go Inside Your Component s Structure If we look at the PhpInfo component you ll find that the web pages live in the src www folder src www is meant to be a folder that holds all of the web pages and related content that you want installed into the computer system Where Does The PEAR Installer Install The Web Pages When you use the PEAR installer to install your component pear install phix PhpInfo all of the web pages get installed into usr share php www on your computer The PEAR installer s behaviour here is almost identical to command line scripts the installer installs your web pages directly into the main www dir folder This does create the potential for clashes where two or more packages want to install files with identical names In practice PHP components include web pages so rarely that the problem is unlikely to happen The test file src www phpinfo php therefore ends up installed onto your computer as usr share php www phpinfo php There s always the possibility that some Linux distros and Mac OS X will install doc files into a different folder You can see where the PEAR installer will put these files on your computer by running sudo pear config show grep www dir PEAR www files directory www dir usr share php www How Do I Get Apache To Serve These Files By default and for very good reasons Apache does not serve content directly from usr share php www You will need to copy any files from usr share php www to your website folders normally found under var www before they can be used 8 comments PHP Components Shipping Unit Tests With Your Component Posted by Stuart Herbert on August 15th 2011 in Examples phix Toolbox In my Beyond Frameworks talk I explained how a component based architecture can help answer some of the important i e expensive questions you might face when creating long lived apps that rely on a PHP framework In this series of blog posts I m going to look at how to go about creating and working with components I m now going under the bonnet of our components and looking at the different file roles that the PEAR installer expects to find when we distribute our component as a PEAR compatible package One of the most important file roles allows you to ship your tests with your package and it s vital that this is something that you get in the habit of doing routinely Test Your Code And Ship Your Tests If you want other developers to re use your code in their projects it is essential that you earn their trust Trust has to be earned over time by establishing a track record of dependability There are many things you need to do to establish such a reputation such as semantic versioning to flag backwards compatibility breaks and writing unit tests to prove that your code works as expected Although the PEAR Installer has long supported shipping unit test code to date the PHP community hasn t really embraced this and it is still very rare for a PEAR package to include unit tests when downloaded This is also compounded by unfortunate legacy choices in some Linux distributions ubuntu bug fedora bug where unit test code currently ends up being installed under the same directory tree as the main code from the PEAR packages something that only really matters since the PHP Community started to adopt PSR 0 as the standard for autoloading What Are PHP Tests PHP tests the test file role supported by the PEAR Installer are executable tests There is currently no formal standard for these tests however PHPUnit has emerged as the community s de facto standard for unit tests and is the approach that the PHP components skeleton supports out of the box to make life much easier for you Just as important as shipping tests is making sure that it is extremely easy for someone who knows nothing about your code to safely and reliably execute any tests that you ship The components skeleton handles much of this for you by including a PHPUnit bootstrap php file and a build xml file with full instructions on how to execute the tests However it is important that you write your tests in a way that doesn t rely on anything that your users won t have installed or configured Where Do Tests Go Inside Your Component s Structure If we look at the CommandLineLibrary component you ll find that the unit test files live in the src tests unit tests folder Important notes The folder structure underneath src tests unit tests exactly matches the folder structure for both PHP scripts and PHP files under the src folder Each unit test script is designed for PSR 0 autoloading just like the PHP scripts that they test Each unit test script ends in the word Test This is a convention that is supported in IDEs such as Netbeans Where Does The PEAR Installer Install The Tests When you use the PEAR installer to install your component pear install phix CommandLineLib all of the test files get installed into usr share php tests package name on your computer The PEAR installer s behaviour here is different to both command line scripts and PHP code the installer creates a sub folder with the name of your package and then installs your test files into this sub folder and not into the main test dir folder This isn t a problem in practice as long as you are aware of the different behaviour here The test file src php unit tests Phix Project CommandLineLib CommandLineParserTest php therefore ends up installed onto your computer as usr share php tests CommandLineLib Phix Project CommandLineLib CommandLineParserTest php There s always the possibility that some Linux distros and Mac OS X will install doc files into a different folder You can see where the PEAR installer will put these files on your computer by running sudo pear config show grep test dir PEAR test directory test dir usr share php tests What About Other Kinds Of Test Code In the PHP component skeleton the src tests functional tests folder is available for anyone who wants to add any automated testing to prove that their app works Selenium is a tool that might help with this There s also the src tests integration tests folder available for anyone who wants to maintain a strict separation between unit tests which technically should prove that a single class works as required and integration tests which technically should prove that a collection of classes work together as required especially across system boundaries At the time of writing the component skeleton doesn t do anything with code inside these folders Patches are most welcome 10 comments Sharing My Reading List Looking For Recommendations Posted by Stuart Herbert on July 31st 2011 in Community Toolbox Training I m a great believer in the power of self education especially if you are or want to be in a more senior role in your firm or organisation A regular reading list is a great way to learn more about how others are solving problems that you might be or are about to be struggling with I ve been surprised at how little people I know read though Over the years I ve built up a list of blogs that I read daily to try and keep up with what is happening in the wider digital world It isn t a complete list for sure but it s a good start I m certain that there are many other blogs out there that belong on this list If you know of any please send me a pull request Be the first to leave a comment Creating PHP 5 34 Packages On Debian Ubuntu Posted by Stuart Herbert on July 31st 2011 in Toolbox I was just wondering if anyone has published instructions on how to take the latest PHP 5 3 and PHP 5 4 source tarballs and turn them into drop in packages for Debian and Ubuntu a la the DotDeb or Damz s packages Be the first to leave a comment PHP Components Shipping Documentation With Your Component Posted by Stuart Herbert on April 28th 2011 in Examples phix Toolbox In my Beyond Frameworks talk I explained how a component based architecture can help answer some of the important i e expensive questions you might face when creating

    Original URL path: http://blog.stuartherbert.com/php/category/toolbox/page/3/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » Toolbox
    website would not host components itself it would track all of the independently published PEAR channels and be the one stop shop for users to come to whenever they needed to find a component to solve a requirement I think this would be a good thing for the PHP ecosystem So requirements What do you want from such a website What do you want it to do How do you want it to work At this stage the sky s the limit Leave your requirements in the comments please and I ll pull them together into a summary post next weekend Once the requirements are stable ish I d like to organise a hackathon to get the first version built and live If you re up for that and want to help make that happen do ping me on Twitter stuherbert Be the first to leave a comment PHP Components Shipping A Command Line Program Posted by Stuart Herbert on April 6th 2011 in Examples phix Toolbox In my Beyond Frameworks talk I explained how a component based architecture can help answer some of the important i e expensive questions you might face when creating long lived apps that rely on a PHP framework In this series of blog posts I m going to look at how to go about creating and working with components I m now going under the bonnet of our components and looking at the different file roles that the PEAR installer expects to find when we distribute our component as a PEAR compatible package One of the useful file roles allows us to install new command line programs such as PHPUnit or Phix onto a computer for everyone to use What Is A Command Line Program A command line program the script file role supported by the PEAR installer is a PHP script that your users run from inside Terminal or Command on Windows It allows you to put powerful tools in the hands of your users You can also run them as scheduled jobs via cron Where Do Command Line Scripts Go Inside The Component s Structure If we take a look at the phix component you ll find the command line program itself in the src bin folder src bin is meant to be a folder that holds the commands that you want installed into the computer system In theory you could put sub folders under here but this is not supported If you look at phix s actual code you ll see that the phix command line program loads code that exists in the src php folder of the component and is installed into usr share php when the PEAR installer installs the component Your classes should go in src php just like with any other component Where Do Command Line Programs Get Installed When you use the PEAR installer to install your component pear install phix phix all of the files in your component s src bin folder gets installed into usr bin on your computer The command line script src bin phix therefore ends up installed onto your computer as usr bin phix The reason why the PEAR installer installs your PHP code under usr bin is because this folder is normally part of a user s search path in Terminal That allows users to run your command line program simply by phix without having to specify the full path to your command line program I haven t seen it personally but there s always the possibility that some Linux distros and Mac OS X will install command line programs into a different folder You can see where the PEAR installer will put these files on your computer by running sudo pear config show grep bin dir PEAR executables directory bin dir usr bin How Do I Make My Command Line Program Executable You re probably used to running PHP scripts from the command line like this php my script php but for command line programs you don t want your users having to remember to run everything through the PHP interpreter each time UNIX and UNIX like operating systems such as Linux have a long tradition of writing command line programs using scripting languages If you put a shebang the characters hash pling at the top of your script you can tell your operating system how to execute your script usr bin env php php PHP code goes here The line usr bin env php tells your operating system to use the PHP CLI interpreter wherever it is in your Terminal s path to run this script Using usr bin env in this way normally makes your script portable across different Linux distros Be the first to leave a comment PHP Components Shipping Reusable PHP Code Posted by Stuart Herbert on April 5th 2011 in Examples phix Toolbox In my Beyond Frameworks talk I explained how a component based architecture can help answer some of the important i e expensive questions you might face when creating long lived apps that rely on a PHP framework In this series of blog posts I m going to look at how to go about creating and working with components I m now going under the bonnet of our components and looking at the different file roles that the PEAR installer expects to find when we distribute our component as a PEAR compatible package To get started I m going to start with the obvious file role the PHP code that a component is all about What Is PHP Code PHP code the php file role supported by the PEAR installer is your component s PHP code This is the code that you want everyone to download and install and then include into their own PHP apps Where Does PHP Code Go Inside The Component s Structure If we take a look at the CommandLineLib component you ll find all of the PHP code for this component under the src php folder src php is meant to be the top of a tree structure that any PSR0 compliant autoloader could load from The first level of folders under src php is by convention the name of the vendor of the code For CommandLineLib the vendor is Phix Project The second level of folder onwards can be whatever you need them to be By convention for our components at work we are using the second level of folders to be the name of the component in this case CommandLineLib This works really well as you start to build up a larger number of components in your PEAR channel And eventually you get down to the actual class definitions themselves The PHP class Phix ProjectCommandLineLibCommandLineParser therefore ends up in the file src php Phix Project CommandLineLib CommandLineParser php Where Does PHP Code Get Installed When you use the PEAR installer to install your component pear install phix CommandLineLib all of the files in your component s src php folder gets installed into usr share php on your computer The PHP class Phix ProjectCommandLineLibCommandLineParser therefore ends up installed onto your computer as usr share php Phix Project CommandLineLib CommandLineParser php The reason why the PEAR installer installs your PHP code under usr share php is because this folder is normally part of PHP s include path That allows developers to include your code simply by doing code lang php include Phix Project CommandLineLib CommandLineParser php code or better still by using a PSR0 compliant autoloader and then simply attempting to create a new instance of the class code lang php load the PSR0 compliant autoloader require once psr0 autoloader php create a new command line parser parser new Phix ProjectCommandLineLibCommandLineParser code Some Linux distros and Mac OS X will use usr lib php instead of usr share php You can see where the PEAR installer will put these files on your computer by running sudo pear config show grep php dir PEAR directory php dir usr lib php Be the first to leave a comment PHP Components ComponentManager 1 1 0 Released Posted by Stuart Herbert on April 4th 2011 in phix Toolbox In my Beyond Frameworks talk I explained how a component based architecture can help answer some of the important i e expensive questions you might face when creating long lived apps that rely on a PHP framework In this series of blog posts I m going to look at how to go about creating and working with components I ve just put out ComponentManager version 1 1 0 with the following hopefully useful changes Improvements To The php library Skeleton Once you ve setup your metadata phing build vendor will build with no errors I ve added an empty src php dummy php file so that a valid empty PEAR compatible package can be build and installed You ll want to remove this file when you start putting your own code into the component New build property project channel Set this to the name of your PEAR channel Automatically picked up by package xml now New build property pear local Set this to the folder where your local copy of your PEAR channel resides See my blog post for details about why you might want a local copy of your PEAR channel New build xml target publish local You can now do phing publish local to use pirum add your component to your local copy of your PEAR channel Bug Fixes For The php library Skeleton Now tested on both Ubuntu and Fedora 14 especially for phpcodemonkey Now excludes DS Store folders from the final component for those using these tools on OS X Now excludes svn folders from the final component Now excludes empty files from the final component How To Upgrade To upgrade your installation please do the following pear clear cache pear upgrade pear pear pear upgrade Gradwell ComponentManager Once the latest version of ComponentManager has been installed you can upgrade the skeletons of your existing components by doing cd where I put it my component phix php library upgrade You will then want to edit build properties to set the new properties added in this release Any problems let me know Be the first to leave a comment PHP Components Explaining File Roles Posted by Stuart Herbert on April 4th 2011 in Examples phix Toolbox In my Beyond Frameworks talk I explained how a component based architecture can help answer some of the important i e expensive questions you might face when creating long lived apps that rely on a PHP framework In this series of blog posts I m going to look at how to go about creating and working with components In previous articles I ve introduced you to the component skeleton that phix creates for you when you run the phix php library init command Our skeleton is designed to be extremely clean so that it is very easy to automatically generate your PEAR compatible component and its package xml file so that you don t have to maintain it yourself a process which would only end in tears At the heart of our skeleton are the design constraints imposed by the PEAR installer and that means the way it handles files differently depending on the file s role What Are File Roles A file s role is simply a way of telling the PEAR installer where you want the file installed The PEAR installer supports the following file roles data any data files that your component needs to read at run time doc documentation about your component php your PHP code script any command line scripts your component includes test your hopefully PHPUnit based tests www PHP code to be served by Apache plus a few more that are of no interest to authors of PHP components Where Do I Put Files For Each Role To make it extremely easy for the phing pear package command to auto generate your package xml file there s a folder in our component skeleton for each type of file Here s a handy summary showing you where to put your files inside your component based on their role data goes in the src data folder doc goes in the src doc folder php goes in the src php folder script goes in the src bin folder test goes in the src tests unit tests folder www goes in the src www folder In the next few articles I m going to look at each of these file roles in turn and show you in detail how the PEAR installer treats them and how to work with them in your own components starting with the php role Be the first to leave a comment PHP Components 3 Tips For Publishing Your Own PEAR Channel Posted by Stuart Herbert on March 31st 2011 in Examples phix Toolbox In my Beyond Frameworks talk I explained how a component based architecture can help answer some of the important i e expensive questions you might face when creating long lived apps that rely on a PHP framework In this series of blog posts I m going to look at how to go about creating and working with components In my last article I looked at how to publish your own PEAR channel and why today that s the best option for you and your projects It takes about 10 minutes to publish your first PEAR channel thanks to Fabien s work on creating Pirum But what is it like to actually work with your own PEAR channel on a long term basis What are the things you could do to make things as easy as possible Tip 1 Local Copy Of Your PEAR Channel Sometimes you develop a component for the sake of it but most of the time you end up writing your components and the app that needs them side by side This is what happened with phix et al and behind the scenes here it is also what is happening with the components for my example app called sental When that happens no matter how focused and skilled your unit testing is you ll want to release preview versions of your component try them in your app and then go back to your component and tweak things all before you re ready to share the next release of your component via your PEAR channel This is what the alpha and beta stability flags in package xml were originally designed for but it s more pragmatic to have a local private copy of your PEAR channel on your dev box and leave those stability flags well alone Here are the steps you need to follow to setup your own private copy of your PEAR channel on a Linux box Setup Apache on your dev box with a virtual host to publish your PEAR channel just like you have done on your public webserver Use pirum to create your PEAR channel s files on your dev box or even better see Tip 3 below Edit etc hosts to have the fully qualified domain name for your PEAR channel point to IP address 127 0 0 1 With this done every time you use the PEAR installer on your dev box to install something from your PEAR channel the PEAR installer will actually download your component from your private copy of your PEAR channel You can keep putting new copies of your component onto this private copy of your PEAR channel until you re satisfied with it and it doesn t matter that you re not actually bumping the version number of your component each time you do so because only you are affected And when you re ready to send this new version out into the world you just need to tag the release in source control and then upload your private copy of your PEAR channel to your public webserver Btw if you do a lot development disconnected from the internet like I do having a local copy of your PEAR channel is pretty much a must Tip 2 Tag Your Releases Once you ve decided that your component is ready to share with everyone on your PEAR channel that s the time to tag your release in source control It s dead easy to do and it gives you and anyone else who takes over maintenance of your code a record of what was in each release Here s how to do it in git stuart Devel sental repustateApi git tag a m Release 0 1 0 0 1 0 stuart Devel sental repustateApi git push tags origin master If you re publishing on GitHub you can then go to your component on there and forever more see your code for that release Here s the repustateApi component at version 0 1 0 on GitHub as a real example of tagged code An even better example is Sebastian Bergmann s PHPUnit project where at the time of writing there are 193 tags to see As an aside we really should be digitally signing these tags but that is a topic in its own right for a later blog post Tip 3 Publish Your PEAR Channel Via Source Control It isn t just the code for your components that can be tracked via source control there is nothing stopping you from publishing your PEAR channel via source control too pear gradwell com is our public PEAR channel and we have a pear gradwell com repo up on GitHub for it This makes it extremely easy to publish new packages to our PEAR channel On my dev box I add a new release to source control like this stuart var www pear gradwell com git clone git github com Gradwell pear gradwell com git stuart var www pear gradwell com pirum add Devel repustateApi dist repustateApi 0 1 0 tgz stuart var www pear gradwell com git add i stuart var www

    Original URL path: http://blog.stuartherbert.com/php/category/toolbox/page/4/ (2016-05-02)
    Open archived version from archive



  •