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 - » PHP Components: Explaining File Roles
    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 About The Author Stuart has been writing PHP applications since 2003 and has been contributing to open source software since 1994 He was an early writer for php architect a 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 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

    Original URL path: http://blog.stuartherbert.com/php/2011/04/04/explaining-file-roles/ (2016-05-02)
    Open archived version from archive


  • Stuart on PHP - » PHP Components: Shipping Reusable PHP Code
    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 About The Author Stuart has been writing PHP applications since 2003 and has been contributing to open source software since 1994 He was an early writer for php architect a 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

    Original URL path: http://blog.stuartherbert.com/php/2011/04/05/php-components-shipping-reusable-php-code/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » PHP Components: Shipping A Command-Line Program
    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 About The Author Stuart has been writing PHP applications since 2003 and has been contributing to open source software since 1994 He was an early writer for php architect a 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 scribu says November 6th 2011 at 12 51 am Hello Is there any way to also ship a bash completion file for the binary It would need to be installed in etc bash completion d Thanks for the awesome PHP Components series btw

    Original URL path: http://blog.stuartherbert.com/php/2011/04/06/php-components-shipping-a-command-line-program/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » PHP Components: Shipping Data Files With Your Components
    component is installed into a vendor directory You ll need to locate these files using a different technique How Do I Locate The Data Files From My PHP Code Take a look at the top of the LibraryComponentFolder class from the ComponentManagerPhpLibrary component code lang php class LibraryComponentFolder extends ComponentFolder const DATA DIR DATA DIR ComponentManagerPhpLibrary php library code DATA DIR is a token that at runtime the PEAR installer expands to be the fully qualified path to the top of the computer s data dir Underneath that you need to remember to add your component s name to the path otherwise you ll be scratching your head and wondering why you can t find the data files The full instructions that tell the PEAR installer to expand this token are added to your component s package xml file when we build the PEAR compatible package I ll look at the final package xml file in detail towards the end of this series of blog posts How Do I Unit Test PHP Code That Relies On Data FIles There is one important downside to this technique any unit tests that rely on loading data from your data directory are going to fail because DATA DIR is only expanded when the PEAR installer installs your component At the time of writing I don t have an easy solution for this but leave it with me and I ll find a solution for this before the end of this series of blog posts About The Author Stuart has been writing PHP applications since 2003 and has been contributing to open source software since 1994 He was an early writer for php architect a 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 till says April 11th 2011 at 4 58 pm Glad you asked You know we all hang out on EFNET in pear and are always there for you Just a BTW from what I can tell we usually don t do foo but foo regardless The solution is simple in a unit test to discover if e g you run from VCS checkout or similar we usually do the following till says April 11th 2011 at 5 00 pm The commenting on your blog is buggy it stripped out my example code Here is a gist https gist github com 913858 till says April 11th 2011 at 5 00 pm The commenting on your blog is buggy it stripped out my example code Here is a gist https gist github com 913858 KingCrunch says April 11th 2011 at 6 10 pm I test my packages by creating a local PEAR repository and install the package including all dependencies there pear config

    Original URL path: http://blog.stuartherbert.com/php/2011/04/11/php-components-shipping-data-files-with-your-components/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » PHP Components: Shipping Documentation With Your Component
    the series The README txt file is also essential at the very least it tells developers where to go to find your component s website and full documentation If you publish your source code via GitHub you can write this file as README md using GitHub s flavour of Markdown and GitHub will automatically pick up the file and display it on your repository s homepage as an example see phix s homepage Quite a few existing PHP components also include a CREDITS txt file although some PHP components prefer to publish this information on their website instead Where Do Docs Go Inside Your Component s Structure If we look at the ComponentManagerPhpLibrary component you ll find that the essential documentation files actually live in the component s top level folder The component skeleton will automatically pick up any files in the top level folder that match the patterns txt or md Where Does The PEAR Installer Install The Docs When you use the PEAR installer to install your component pear install phix ComponentManagerPhpLibrary all of the documentation files get installed into usr share php docs 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 doc files into this sub folder and not into the main doc dir folder This isn t a problem in practice as long as you are aware of the different behaviour here The doc file README md therefore ends up installed onto your computer as usr share php docs ComponentManagerPhpLibrary README md 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 doc dir PEAR documentation directory doc dir usr share php docs Okay So What Should We Do About Proper Documentation Anyone getting started with your component clearly needs a lot more documentation than a LICENSE and a basic README Unfortunately as discussed at the start of this article today the PEAR installer has poor support for shipping the sort of high quality in depth documentation that your users both expect and deserve For now the right thing to do is to publish your documentation on a website I m going to look at that in detail later in this series after I have finished looking at the rest of the file roles supported by the PEAR installer About The Author Stuart has been writing PHP applications since 2003 and has been contributing to open source software since 1994 He was an early writer for php architect a 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

    Original URL path: http://blog.stuartherbert.com/php/2011/04/28/php-components-shipping-documentation-with-your-component/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » PHP Components: Shipping Unit Tests With Your Component
    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 About The Author Stuart has been writing PHP applications since 2003 and has been contributing to open source software since 1994 He was an early writer for php architect a 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 10 Comments Christian Weiske says August 15th 2011 at 8 34 am You can run the unit tests from the package via PEAR too pear run tests up package name requires a AllTests php file though Stuart Herbert says August 16th 2011 at 4 04 pm Christian thanks That doesn t seem to be documented anywhere in PEAR s documentation Christian Weiske says August 15th 2011 at 8 34 am You can run the unit tests from the package via PEAR too pear run tests up package name requires a AllTests php file though Stuart Herbert says August 16th 2011 at 4 04 pm Christian thanks That doesn t seem to be documented anywhere in PEAR s documentation Daniel O Connor says August 15th 2011 at 11 59 pm One of the things many authors within PEAR aren t 100 clear on is where tests should be runnable from The defacto feeling within PEAR is that your package should not need to be installed to enable tests I tend towards saying tests should always be executed from the top level src directory Say you have a component living in My Component php cd My Component trunk src phpunit tests Your test would simply require once My Component php and execute happily When installed by the PEAR installer it would locate My Component php in the include path and also execute This avoids any need to do require once dirname FILE path to my trunk src My Component php and ensures that when you are in the top level directory your tests are running on your local svn version not a different installed version The one problem I see and don t tend to have a great answer for is components with dependencies the installer solves this problem but there are few reliable ways to check that all dependencies are available and installed when running your tests from version control directly Mechanisms like svn externals can go some way towards fixing this or pre installing your dependencies but neither is a clean solution Daniel O Connor says August 15th 2011 at 11 59 pm One of the things many authors within PEAR aren t 100 clear on

    Original URL path: http://blog.stuartherbert.com/php/2011/08/15/php-components-shipping-unit-tests-with-your-component/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » PHP Components: Shipping Web Pages With Your Components
    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 About The Author Stuart has been writing PHP applications since 2003 and has been contributing to open source software since 1994 He was an early writer for php architect a 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 8 Comments Christian Weiske says August 16th 2011 at 6 41 am Where Does The PEAR Installer Install The Tests all of the test files get installed into usr share php www wtf Stuart Herbert says August 16th 2011 at 2 49 pm Massimalliano Christian thanks fixed that error Christian Weiske says August 16th 2011 at 6 41 am Where Does The PEAR Installer Install The Tests all of the test files get installed into usr share php www wtf Stuart Herbert says August 16th 2011 at 2 49 pm Massimalliano Christian thanks fixed that error Massimiliano Arione says August 16th 2011 at 12 07 pm Maybe you did too much copy paste Where Does The PEAR Installer Install The Tests should be something with pages instead of tests Same for sentence all of the test files get installed Massimiliano Arione says August 16th 2011 at 12 07 pm Maybe you did too much copy paste Where Does The PEAR Installer Install The Tests should be something with pages instead of tests Same for sentence all of the test files get installed Stuart Herbert On PHP PHP Components Shipping Web Pages With Linux Blog says August 17th 2011 at 4 40 am you might face when creating long lived apps that rely on a PHP framework Read more Stuart Herbert On PHP PHP Components Shipping Web Pages With This entry was posted in Uncategorized and tagged answer some beyond frameworks explained how Stuart Herbert On PHP PHP Components Shipping Web Pages With Linux Blog says August

    Original URL path: http://blog.stuartherbert.com/php/2011/08/16/php-components-shipping-web-pages-with-your-components/ (2016-05-02)
    Open archived version from archive

  • Stuart on PHP - » HubFlow – GitHub and the GitFlow Model Together
    architect a 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 2 Comments hakre says June 12th 2012 at 10 17 am 404 on this one Using GitFlow With GitHub this is probably the page you re really looking for Stuart Herbert says June 12th 2012 at 1 19 pm Thanks Should be fixed just as soon as the next GitHub pages build completes 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 June 2012 M T W T F S S May Jul 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Recent Posts

    Original URL path: http://blog.stuartherbert.com/php/2012/06/12/hubflow-github-and-the-gitflow-model-together/ (2016-05-02)
    Open archived version from archive



  •