{"id":100,"date":"2010-05-23T13:27:18","date_gmt":"2010-05-23T05:27:18","guid":{"rendered":"http:\/\/karyleong.net\/?p=100"},"modified":"2010-05-23T13:27:18","modified_gmt":"2010-05-23T05:27:18","slug":"best-encode-for-php5-and-support-symfony","status":"publish","type":"post","link":"https:\/\/karyleong.net\/?p=100","title":{"rendered":"Best Encode for PHP5 and support symfony"},"content":{"rendered":"<p>In symfony, encoded classes excluded from config_autoload_yml.php. Because when symfony found the classes and read the contents, symfony can not find the words that contain abstract class|interface, final class|interface, class.<\/p>\n<p>Following is the\u00a0solution to make it work.<\/p>\n<p>1. create config_handlers.yml in sf_root_dir\/config folder and add<\/p>\n<pre>config\/autoload.yml:\r\n  class:    myAutoloadConfigHandler\r\n<\/pre>\n<p>2. add myAutoloadConfigHandler.class.php to sf_root_dir\/config<br \/>\n<code><br \/>\n<?php\nclass myAutoloadConfigHandler extends sfAutoloadConfigHandler\n{\n\tstatic public function parseFile($path, $file, $prefix)\n  {\n    $mapping = array();\n    $content = file_get_contents($file);\n    preg_match_all('~^\\s*(?:abstract\\s+|final\\s+)?(?:class|interface)\\s+(\\w+)~mi', $content, $classes);\n\t\t\n    if (count($classes[1]) == 0)\n    {\n      if (stristr($content, 'ioncube_loader') !== FALSE)\n      {\n\t\t\t\tpreg_match_all('~^\/\/\\s*(?:abstract\\s+|final\\s+)?(?:class|interface)\\s+(\\w+)~mi',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t $content, $classes);\n      }\n    }\n\n    foreach ($classes[1] as $class)\n    {\n      $localPrefix = '';\n      if ($prefix)\n      {\n        \/\/ FIXME: does not work for plugins installed with a symlink\n        preg_match('~^'.str_replace('\\*', '(.+?)', preg_quote(str_replace('\/', DIRECTORY_SEPARATOR, $path), '~')).'~', str_replace('\/', DIRECTORY_SEPARATOR, $file), $match);\n        if (isset($match[$prefix]))\n        {\n          $localPrefix = $match[$prefix].'\/';\n        }\n      }\n\n      $mapping[$localPrefix.strtolower($class)] = $file;\n    }\n    return $mapping;\n  }\n}\n<\/code><\/p>\n<p>3. change ProjectConfiguration.class.php and add myAutoloadConfigHandler.class.php<br \/>\n<code><br \/>\n  public function setup()<br \/>\n  {<br \/>\n    require_once(sfConfig::get('sf_root_dir').'\/config\/myAutoloadConfigHandler.class.php');<br \/>\n<\/code><\/p>\n<p>4. using <a href=\"http:\/\/www.ioncube.com\/sa_encoder.php?xp=YAQHKD\" target=\"_blank\">ionCude Encoder<\/a> to encode the files and add comment \"class sfClassName\" to the encode file.<br \/>\nExample: myTools.class.php<br \/>\n<code><br \/>\n<?php \/\/00451\n\/\/ IONCUBE ENCODER 6.5 EVALUATION\n\/\/ THIS LICENSE MESSAGE IS ONLY ADDED BY THE EVALUATION ENCODER AND\n\/\/ IS NOT PRESENT IN PRODUCTION ENCODED FILES\n\n<strong>\/\/ class myTools<\/strong><br \/>\nif(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');@dl($__ln);if(function_exists('_il_exec')){return _il_exec();}$__ln='\/ioncube\/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\\\','\/',substr($__id,2));$__here=str_replace('\\\\','\/',substr($__here,2));}$__rd=str_repeat('\/..',substr_count($__id,'\/')).$__here.'\/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='\/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}@dl($__ln);}else{die('The file '.__FILE__.\" is corrupted.\\n\");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file <b>'.__FILE__.'<\/b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the site administrator.');exit(199);<br \/>\n?><br \/>\n4+oV5Djj\/RjxxiMy5hHec2J9iSWGrP53JymQThUitFyI+rDD9TZc2z8BXRg+rQoi2zlgyd1jv271<br \/>\nLGLiuMCfZM9Wyo97ZTp208rr6ekINq15uTrYKONgK8dPivUR3GzHKXjbKRNv+toLg2bgkSIlKTzC<br \/>\n3KaXVdeReVGarLrmVxaC7L3pJ4Lt1Nex\/HVwg3foRqvLGrv0vowUiL1k4uv87wuEJhST20s\/KQ6M<br \/>\n8JwWXKksGBPbJ3cDMQuODDnHqNo\/\/6G0VT4kAb4NP\/LU9ejObXbOZx25YnWCgS1kyeeANpe++7Tv<br \/>\nrGwE4smPZpXuQawA5zZR2esxUiftfJXP4Pc0QmUUJRwcQhf2brOmWtb9JchulRNIRLgUxzmcYXk3<br \/>\n2z4KuvH3XkH\/r2MnNXwiL1T172aBUF65ScDqVF3gZqJX1sOqvDwfqcVOPTA7PV1WUcGFbM58y0Cs<br \/>\n<\/code><\/p>\n<p>5. Now your files will be able auto load by the symfony.<\/p>\n<p>6. Some link for ionCube<br \/>\n* The ionCube Home page<br \/>\n<a href=\"http:\/\/www.ioncube.com?xp=YAQHKD\">ioncube.com<\/a><br \/>\n* The Standalone Encoder<br \/>\n<a href=\"http:\/\/www.ioncube.com\/sa_encoder.php?xp=YAQHKD\"><br \/>\nionCube Standalone PHP Encoder<\/a><br \/>\n* The online Encoder<br \/>\n<a href=\"http:\/\/www.ioncube.com\/online_encoder.php?xp=YAQHKD\"><br \/>\nionCube Online PHP Encoder<\/a><\/p>\n<p>7. Finally, I have write a task to encode the files, if you need the task file, please send a email to me. I will send the file to you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In symfony, encoded classes excluded from config_autoload_yml.php. Because when symfony found the classes and read the contents, symfony can not find the words that contain abstract class|interface, final class|interface, class. Following is the\u00a0solution to make it work. 1. create config_handlers.yml in sf_root_dir\/config folder and add config\/autoload.yml: class: myAutoloadConfigHandler 2. add myAutoloadConfigHandler.class.php to sf_root_dir\/config 4+oV5Djj\/RjxxiMy5hHec2J9iSWGrP53JymQThUitFyI+rDD9TZc2z8BXRg+rQoi2zlgyd1jv271 LGLiuMCfZM9Wyo97ZTp208rr6ekINq15uTrYKONgK8dPivUR3GzHKXjbKRNv+toLg2bgkSIlKTzC &#8230; <a title=\"Best Encode for PHP5 and support symfony\" class=\"read-more\" href=\"https:\/\/karyleong.net\/?p=100\" aria-label=\"More on Best Encode for PHP5 and support symfony\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,3],"tags":[58,59,57],"_links":{"self":[{"href":"https:\/\/karyleong.net\/index.php?rest_route=\/wp\/v2\/posts\/100"}],"collection":[{"href":"https:\/\/karyleong.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/karyleong.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/karyleong.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/karyleong.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=100"}],"version-history":[{"count":1,"href":"https:\/\/karyleong.net\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions"}],"predecessor-version":[{"id":101,"href":"https:\/\/karyleong.net\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions\/101"}],"wp:attachment":[{"href":"https:\/\/karyleong.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/karyleong.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/karyleong.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}