{"id":950,"date":"2018-07-31T13:36:46","date_gmt":"2018-07-31T13:36:46","guid":{"rendered":"https:\/\/codingfix.com\/?p=950"},"modified":"2024-09-02T15:58:22","modified_gmt":"2024-09-02T15:58:22","slug":"installing-phpdocumentor-issues-solved","status":"publish","type":"post","link":"https:\/\/codingfix.com\/installing-phpdocumentor-issues-solved\/","title":{"rendered":"Installing phpDocumentor issues solved!"},"content":{"rendered":"\n<p>Installing phpDocumentor should be easy. At least, I read here and there in the Internet, besides of course in the <a href=\"https:\/\/www.phpdoc.org\/\" target=\"_blank\" rel=\"noopener\">official website<\/a>,&nbsp; that you have many options to install it, one easier of the previous one!<\/p>\n\n\n\n<p>So I was absolutely confident that in a bunch of minutes I&#8217;d have been able to run phpDocumentor and create the documentation for my new Php class.<\/p>\n\n\n\n<p>Do you know? I was wrong. This is what happened.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"phpdocumentor-phar\">phpDocumentor.phar<\/h2>\n\n\n\n<p>The first thing I tried it has been to use the .phar file. I know the first way they suggest is to use PEAR, but I have had a positive experience about using .phar files just a day before: I wanted to have php-cs-fixer setup and running in Atom and after several attempts I ended up using php-cs-fixer.phar file. So, when ti came the moment to install phpDocumentor I told myself: &#8220;why should I have to struggle with the command line, dependencies issues and the rest when I can just download a single, wonderful file and put in my php directory?&#8221; Done! Once I had phpDocumentor.phar installed, I have opened the command prompt directly in my class folder and typed<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">phpdoc -d \".\" -t \".\/docs\"<\/pre>\n\n\n\n<p>BUUUZZZZ!!!<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Could not open&nbsp;input file: &#8220;phpDocumentor.phar&#8221;<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-phpdocumentor-with-composer\">Installing phpDocumentor with Composer<\/h2>\n\n\n\n<p>Wooops, what&#8217;s this? Started googling a bit, but with no success, so I sadly abandoned the .phar file and I went on with Composer. worst than before!<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>phpdoc is not recognized as an internal or external command<\/p>\n<\/blockquote>\n\n\n\n<p>To Google or not to Google? No, I don&#8217;t want to waste time to understand why something is told to work doesn&#8217;t work (not talking about Composer itself, which is a great tool I use in several occasions, just talking about installing phpDocumentor via Composer). Filed attempt.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"installing-phpdocumentor-with-pear\">Installing phpDocumentor with PEAR<\/h2>\n\n\n\n<p>I always had good experience installing php extensions through PEAR so I thought it would have worked even installing phpDocumentor. I typed the following command and I eagerly awaited the response:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pear channel-discover pear.phpdoc.org\npear install phpdoc\/phpDocumentor<\/pre>\n\n\n\n<p>Wow, everything seemed to go fine! Once the process has finished, I have done another attempt to create my documentation typing the usual command:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">phpdoc -d \".\" -t \".\/docs\"<\/pre>\n\n\n\n<p>Aaarrghhh!!! The command prompt window has been filled with a lot of warnings and errors related to Smarty templates!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-solution\">The solution<\/h2>\n\n\n\n<p>I will spare you the details. I just say that thirty\/forty minutes of googling gave me the solution: downloading the version 2.9.0 directly from Github. I went to&nbsp;<a href=\"https:\/\/github.com\/phpDocumentor\/phpDocumentor2\/releases\/tag\/v2.9.0\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/phpDocumentor\/phpDocumentor2\/releases\/tag\/v2.9.0<\/a> and clicked to the compressed file with the name <a href=\"https:\/\/github.com\/phpDocumentor\/phpDocumentor2\/releases\/download\/v2.9.0\/phpDocumentor-2.9.0.tgz\" target=\"_blank\" rel=\"noopener\">phpDocumentor-2.9.0.tgz<\/a>&nbsp;to download it and&#8230; Don&#8217;t ask me why, maybe that day I was terribly unlucky, but the download was terribly slow, it stopped several times and once it has been completed, the archive was corrupted!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"the-true-solution\">The true solution!<\/h2>\n\n\n\n<p>Fortunately I have found another website which allows to download that file:&nbsp;<a href=\"https:\/\/fossies.org\/linux\/www\/phpDocumentor-2.9.0.tgz\/\" target=\"_blank\" rel=\"noopener\">https:\/\/fossies.org\/linux\/www\/phpDocumentor-2.9.0.tgz\/<\/a>. Finally, I&#8217;ve got the file. I put it in a temporary folder, opened the command prompt and simply typed:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pear install phpDocumentor-2.9.0.tgz<\/pre>\n\n\n\n<p>A small adjustement to the file phpdoc.bat is still missing. Go in your php folder (In my Windows 10 partition I have installed xampp, so my php is located in C:\\xampp\\php folder) and open phpdoc.bat with a text editor. It should look like this:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">BAT (Batchfile)<\/span><span role=\"button\" tabindex=\"0\" data-code=\"@echo off\nif &quot;%PHPBIN%&quot; == &quot;&quot; set PHPBIN=php.exe\nif not exist &quot;%PHPBIN%&quot; if &quot;%PHP_PEAR_PHP_BIN%&quot; neq &quot;&quot; goto USE_PEAR_PATH\nGOTO RUN\n:USE_PEAR_PATH\nset PHPBIN=%PHP_PEAR_PHP_BIN%\n:RUN\n&quot;%PHPBIN%&quot; &quot;%PHP_PEAR_BIN_DIR%\\phpdoc&quot; %*\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">@<\/span><span style=\"color: #569CD6\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">off<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHPBIN%<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\"> == <\/span><span style=\"color: #CE9178\">&quot;&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">set<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">PHPBIN<\/span><span style=\"color: #D4D4D4\">=php.exe<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> not <\/span><span style=\"color: #569CD6\">exist<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHPBIN%<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHP_PEAR_PHP_BIN%<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\"> neq <\/span><span style=\"color: #CE9178\">&quot;&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #C586C0\">goto<\/span><span style=\"color: #D4D4D4\"> USE_PEAR_PATH<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">GOTO<\/span><span style=\"color: #D4D4D4\"> RUN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">:<\/span><span style=\"color: #569CD6\">USE_PEAR_PATH<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">set<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">PHPBIN<\/span><span style=\"color: #D4D4D4\">=<\/span><span style=\"color: #9CDCFE\">%PHP_PEAR_PHP_BIN%<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">:<\/span><span style=\"color: #569CD6\">RUN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHPBIN%<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHP_PEAR_BIN_DIR%<\/span><span style=\"color: #CE9178\">\\phpdoc&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">%*<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Just change the last line replacing&nbsp;<span class=\"lang:default decode:true crayon-inline \">&#8220;%PHP_PEAR_BIN_DIR%\\phpdoc&#8221;<\/span>&nbsp; with the plain full path to your phpdoc file. In my case, the resulting phpdoc.bat file looks liek this:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">BAT (Batchfile)<\/span><span role=\"button\" tabindex=\"0\" data-code=\"@echo off\nif &quot;%PHPBIN%&quot; == &quot;&quot; set PHPBIN=php.exe\nif not exist &quot;%PHPBIN%&quot; if &quot;%PHP_PEAR_PHP_BIN%&quot; neq &quot;&quot; goto USE_PEAR_PATH\nGOTO RUN\n:USE_PEAR_PATH\nset PHPBIN=%PHP_PEAR_PHP_BIN%\n:RUN\n&quot;%PHPBIN%&quot; &quot;C:\\xampp\\php\\phpdoc&quot; %*\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D4D4D4\">@<\/span><span style=\"color: #569CD6\">echo<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">off<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHPBIN%<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\"> == <\/span><span style=\"color: #CE9178\">&quot;&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">set<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">PHPBIN<\/span><span style=\"color: #D4D4D4\">=php.exe<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> not <\/span><span style=\"color: #569CD6\">exist<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHPBIN%<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #C586C0\">if<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHP_PEAR_PHP_BIN%<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\"> neq <\/span><span style=\"color: #CE9178\">&quot;&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #C586C0\">goto<\/span><span style=\"color: #D4D4D4\"> USE_PEAR_PATH<\/span><\/span>\n<span class=\"line\"><span style=\"color: #C586C0\">GOTO<\/span><span style=\"color: #D4D4D4\"> RUN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">:<\/span><span style=\"color: #569CD6\">USE_PEAR_PATH<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">set<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">PHPBIN<\/span><span style=\"color: #D4D4D4\">=<\/span><span style=\"color: #9CDCFE\">%PHP_PEAR_PHP_BIN%<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">:<\/span><span style=\"color: #569CD6\">RUN<\/span><\/span>\n<span class=\"line\"><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #9CDCFE\">%PHPBIN%<\/span><span style=\"color: #CE9178\">&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;C:\\xampp\\php\\phpdoc&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">%*<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>That&#8217;s all, now it works! And I&#8217;ve got my full documentation with my favourite template:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" data-code=\"phpdoc -d &quot;.&quot; -t &quot;.\/docs&quot; --template=&quot;responsive-twig&quot;\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #DCDCAA\">phpdoc<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">-d<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;.&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">-t<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #CE9178\">&quot;.\/docs&quot;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">--template=<\/span><span style=\"color: #CE9178\">&quot;responsive-twig&quot;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>If you have found useful this article, please share it through your social networks. If you want to leave me a comment, I&#8217;ll be happy to hear from you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing phpDocumentor should be easy. At least, I read here and there in the Internet, besides of course in the official website,&nbsp; that you have many options to install it, one easier of the previous one! So I was absolutely confident that in a bunch of minutes I&#8217;d have been able to run phpDocumentor and [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":953,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gspb_post_css":"","footnotes":""},"categories":[34],"tags":[],"post_folder":[142],"class_list":["post-950","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-other-stuff"],"_links":{"self":[{"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/posts\/950","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/comments?post=950"}],"version-history":[{"count":0,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/posts\/950\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/media\/953"}],"wp:attachment":[{"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/media?parent=950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/categories?post=950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/tags?post=950"},{"taxonomy":"post_folder","embeddable":true,"href":"https:\/\/codingfix.com\/wp-json\/wp\/v2\/post_folder?post=950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}