Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Unix command line:</strong></p> <p>These are the steps I took to implement PSR-0 in my Kohana application.</p> <p>I removed the following system/ dir:</p> <pre><code>rm -rf system </code></pre> <p>In your current bootstrap.php the only change is to make the classes start with an upper, so best is to keep your old bootstrap and just change the following lines on top of the file:</p> <pre><code>// Load the core Kohana class require SYSPATH.'classes/Kohana/Core'.EXT; if (is_file(APPPATH.'classes/Kohana'.EXT)) { // Application extends the core require APPPATH.'classes/Kohana'.EXT; } else { // Load empty core extension require SYSPATH.'classes/Kohana'.EXT; } </code></pre> <p>Remove the bootstrap.php from the new kohana release dir. Now copy paste all files of 3.3 to your old application:</p> <pre><code>cp -R path/to/new/kohana/* . </code></pre> <p>Now move all your controllers and models to the capitalised dirs and remove the old dirs:</p> <pre><code>mv application/classes/controller/* application/classes/Controller mv application/classes/model/* application/classes/Model rm -rf application/classes/controller application/classes/model </code></pre> <p>The vendor dir has a fixed place in the root of the kohana dir. Move your vendor dir from application/vendor (if you have one there) to vendor/</p> <pre><code>mv application/vendor . </code></pre> <p>Edit the database config file (e.g. application/config/database.php), all "type" properties should be capitalised:</p> <pre><code> return array ( 'default' =&gt; array ( 'type' =&gt; 'MySQL', </code></pre> <p>When you use the AUTH orm driver and you have overwritten the config in application/config/auth.php, uppercase the driver name:</p> <pre><code>return array( 'driver' =&gt; 'ORM', </code></pre> <p>Now comes the tricky part, all class names and file names of these classes should be capitalised. Go to the classes dir.</p> <pre><code>cd application/classes </code></pre> <p>And copy paste this command:</p> <pre><code> for SRC in `find . -depth` do DST=`dirname "${SRC}"`/`basename "${SRC}" | sed -e 's/^./\U&amp;/'`; if [ "${SRC}" != "${DST}" ] then [ ! -e "${DST}" ] &amp;&amp; mv -T "${SRC}" "${DST}" || echo "${SRC} was not renamed" fi done </code></pre> <p>(source: <a href="http://forum.kohanaframework.org/discussion/comment/73089#Comment_73089" rel="nofollow noreferrer">http://forum.kohanaframework.org/discussion/comment/73089#Comment_73089</a>)</p> <p>This command recursively checks all dirs and capitalizes the filenames. Go to the application dir.</p> <pre><code>cd ../ </code></pre> <p>Now inside the models and controllers (and helpers), capitalise all class names. So Controller_template_parent must become Controller_Template_Parent. I have some very inefficient commands for this one (so please contribute).</p> <pre><code>find ./ -name \*.php -exec sed -i "s/helper_\([a-zA-Z]\+\)/Helper_\u\1/gI" {} \; find ./ -name \*.php -exec sed -i "s/helper_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)/Helper_\u\1_\u\2/gI" {} \; find ./ -name \*.php -exec sed -i "s/helper_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)/Helper_\u\1_\u\2_\u\3/gI" {} \; </code></pre> <p>The ./ in the beginning is for all files (recursive dirs), that end in .php. I added a "I" behind the sed command to make the search case insensitive. (source command: <a href="https://askubuntu.com/questions/84007/find-and-replace-text-within-multiple-files">https://askubuntu.com/questions/84007/find-and-replace-text-within-multiple-files</a>)</p> <p>The first command will replace helper_some_thing_here with Helper_Some_thing_here. The second command will convert helper_some_thing_here to Helper_Some_Thing_here etc. So if you have class names with more than 3 underscores in it, you can build your own command.</p> <p>The same needs to be done for classes starting with Model_ and Controller_</p> <pre><code>find ./ -name \*.php -exec sed -i "s/model_\([a-zA-Z]\+\)/Model_\u\1/gI" {} \; find ./ -name \*.php -exec sed -i "s/model_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)/Model_\u\1_\u\2/gI" {} \; find ./ -name \*.php -exec sed -i "s/model_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)/Model_\u\1_\u\2_\u\3/gI" {} \; find ./ -name \*.php -exec sed -i "s/controller_\([a-zA-Z]\+\)/Controller_\u\1/gI" {} \; find ./ -name \*.php -exec sed -i "s/controller_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)/Controller_\u\1_\u\2/gI" {} \; find ./ -name \*.php -exec sed -i "s/controller_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)/Controller_\u\1_\u\2_\u\3/gI" {} \; </code></pre> <p>Now some class names that were used with only 1 capital, are now written in full capitals (Html, Url, Http, UTF8). Replace them in your whole application. </p> <p>Execute this command in the application/ dir:</p> <pre><code>find ./ -name \*.php -exec sed -i "s/Url::/URL::/gI" {} \; find ./ -name \*.php -exec sed -i "s/Html::/HTML::/gI" {} \; find ./ -name \*.php -exec sed -i "s/Http::/HTTP::/gI" {} \; find ./ -name \*.php -exec sed -i "s/Utf8::/UTF8::/gI" {} \; </code></pre> <p>When you use the ORM driver, all your Orm::factory('some_class') should be upper cased and capitalised to ORM::factory('Some_Class'). I use the same command to uppercase all ORM classes and to capitalise the class names in the factory.</p> <pre><code>find ./ -name \*.php -exec sed -i "s/orm::factory(\(\"\|'\)\([a-zA-Z_]\+\)\(\"\|'\)\(,[^,]*\)*)/ORM::factory('\u\2'\4)/gI" {} \; find ./ -name \*.php -exec sed -i "s/orm::factory(\(\"\|'\)\([a-zA-Z]\+\)_\([a-zA-Z]\+\)\(\"\|'\)\(,[^,]*\)*)/ORM::factory('\u\2_\u\3'\5)/gI" {} \; find ./ -name \*.php -exec sed -i "s/orm::factory(\(\"\|'\)\([a-zA-Z]\+\)_\([a-zA-Z]\+\)_\([a-zA-Z]\+\)\(\"\|'\)\(,[^,]*\)*)/ORM::factory('\u\2_\u\3_\u\4'\6)/gI" {} \; </code></pre> <p>Now my modules where not compatible anymore since 3.3, not all of them are upgraded. When you want to upgrade them yourself, you probably have to check them separately go to the classes dir of every module, capitalise it's file and it's class names. You can use previous commands.</p> <p>For me this is a checklist when upgrading an application, like I said, please feel free to contribute so upgrading is made easier.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload