PhpDocumentor for Laravel 5.7/6.x - php

This might be a very newbie question but, how exactly do you use phpDocumentor to generate your docs through Laravel? In my Laravel project there's no phpdoc in the vendor/bin directory, and trying to install phpDocumentor via composer fails (as suggested on the GitHub page).
I couldn't find any recent resources about it, the only thing I had luck with is running the phpDocumentor.phar file from the terminal, but the newest version fails immediately.

To get this working, downgrade to PHP 7.1. Then download the latest phpDocumentor.phar file from [http://www.phpdoc.org/phpDocumentor.phar]. Place the phpDocumentor.phar into your Laravel 6.x project's /vendor/bin/ directory.
Then use Homebrew to install other needed packages...
brew install intltool
brew install graphviz
Lastly, cd into /vendor/bin and run...
php phpDocumentor.phar -d ../../app/Http/Controllers
Your documentation output should be at /vendor/bin/output.

Adding a more complete solution that worked for me on creating documentation of my Laravel project with the system environment comprising of MacOS Catalina,Laravel 6 and PHP 7.2.
Visit https://docs.phpdoc.org/3.0/guide/getting-started/installing.html. To install the dependencies, recommended to update homebrew as brew update and brew upgrade. After updating the homebrew, execute the following:
brew install graphviz
brew install plantuml
Once the dependencies are installed, download the phpDocumentor.phar from the above link, and make the file executable as follows:
chmod +x phpDocumentor.phar
Then, copy and paste this file to your laravel app under /vendor/bin
I also placed this file under local bin mv phpDocumentor.phar /usr/local/bin/phpDocumentor for easier access (as shown in step 6 below).
For testing purpose, create a simple test.php file under /vendor/bin/docs/test.php directory with the following content as mentioned in https://docs.phpdoc.org/3.0/guide/getting-started/your-first-set-of-documentation.html
<?php
/**
* This is a DocBlock.
*/
function associatedFunction()
{
}
Then execute the phpdoc script from the same /vendor/bin location as:
phpDocumentor.phar -d docs/test.php -t docs/test
This will generate several files.
Open the index.html file generated in your web browser (eg. Chrome) to view the documentation:
open -a "Google Chrome" ./docs/test/index.html
Notably, because we placed the phpDocumentor.phar in /usr/local/bin/phpDocumentor/phpDocumentor.phar, we can easily access phpdoc and easily create the documentation of our whole App as follows ( the documentation will be stored inside the folder DOCS)
phpDocumentor.phar -d app/ -t DOCS/

I have found the problem with most PHP documentation solutions is they require large amounts of code just to get something you can actually use. And that takes a lot of time and trial and error to set up.
I also have issues with the generated documentation. Often it is not even sorted! Also it is hard to navigate and understand the whole class. As a consumer of a class, you are not interested in private or even protected things (unless you are trying to extend it). But often the docs only show you the methods and properties of the current class, and not what it inherits (which is the WHOLE point of OO!).
Anyway, I got sick of the current state of PHP documentation and decided to do it right. I wrote PHPFUI/InstaDoc to address all the issues I had with existing solutions. InstaDoc is the fastest document generator out there because it simply scans the class directory structure and saves it off. This generally only takes a few seconds (for large code bases) each time you generate (on release, or if you add a new class in your dev env). Then it renders the docs for a specific class at runtime, because, hey, who ever looks at the documentation anyway? Just us nerds, and there are not many of us, and we can wait a fraction of a second for the server to generate the docs on the fly. Also you don't need server disk space to store all your docs. They are generated on the fly. And of course if you have a high volume site, InstaDoc can generate static HTML files, but who has a high volume PHP doc site (like nobody).
Anyway, check out a live example at PHPFUI/InstaDoc and see if it fits your needs. It is not a Laravel module or plug in, but you should be able to run it under Laravel easily. Just return the output of the controller in your controller, and it should just work.

Related

Building php5.3 with ./configure not creating a Makefile

I'm using ubuntu 14.04, attempting to build and install php 5.3.22. I am unable to build as when I enter 'make' I get:
make: *** No targets specified and no makefile found. Stop.
Doing some research, it means that there is no Makefile, which should have been created when I ran ./configure. I got no error or feedback when running ./configure, nor do I get anything when I run ./configure --help. I'm in the correct build directory, otherwise I would get 'command not found?'
Other solutions suggest running autogen.sh, but I think that's only when you are building from a repo.
I also read that there should be a Makefile.in file somewhere, but I do not see that in the directory.
I just want to be able to properly configure and get a generated Makefile so I can build.
To generate the configure script, try running ./buildconf --force. I've not done this myself but got this by looking at the source repo and a couple of Google searches.
Before you can build PHP you first need to obtain its source code. There are two ways to do this: You can either download an archive from PHP’s download page or clone the git repository from git.php.net (or the mirror on Github).
The build process is slightly different for both cases: The git repository doesn’t bundle a configure script, so you’ll need to generate it using the buildconf script, which makes use of autoconf. Furthermore the git repository does not contain a pregenerated parser, so you’ll also need to have bison installed.
PHP Internals Book

Laravel system info

Is it possible to automatically display system info of Laravel (such as laravel version, installed dependency, dependency version and etc) onto the webpage?
Thank you.
The info about stuff managed by Composer is returned with composer show -i (show installed dependencies) from the command line.
I'm pretty sure you should be able to include the composer code directly, ask the same question and avoid the command line, but I have yet to fine out how.
The other method might be to load the contents of composer.lock or vendor/composer/installed.json, parse and display them. Be prepared to experience changing file formats, because that is no official API, but a shortcut.

Trouble installing Omnipay via Netbeans composer extension

I am currently trying to install Omnipay into my Codeigniter project. I am stuck on windows because I do not have ssh access to the box where this needs to run on. So far I have gotten a new directory in the project root that is named "vendor" and it contains a lot of empty directories referring to Symfony (for what reason is beyond me).
Then I get a runtime exception that I need to enable the openssl extension in my php to download the necessary files and this is where I am stuck at. I don't run WAMP on my computer and I just use the php.exe I downloaded to work with netbeans.
Isn't there an easier way to get omnipay to run? Like just download the files from somewhere and plug them into my project like normal? It seems to be an aweful lot of headache to get a simple library to run in my CI project.
Please forgive my ignorance towards composer but I currently see no benefit of using it for this particular project.
You can "just download" the files here: https://github.com/omnipay/common/archive/master.zip
The problem is, Omnipay depends on Guzzle (an HTTP library), and Guzzle depends on some Symfony components. So you will spend the rest of the day downloading dependencies and making sure you have all the necessary files. That is the problem Composer solves for you.
I don't have any experience running Composer on Windows, but I would start here:
http://getcomposer.org/doc/00-intro.md#installation-windows
Using the Installer
This is the easiest way to get Composer set up on your machine.
Download and run Composer-Setup.exe, it will install the latest
Composer version and set up your PATH so that you can just call
composer from any directory in your command line.
Once you have Composer installed, you should simply be able to make a file named composer.json in your project root, with the following contents:
{
"require": {
"omnipay/omnipay": "~2.0"
}
}
Then use the Command Prompt and cd to your project's directory, and run composer update to download the Omnipay files and all their dependencies.

Point local version of a PEAR Package to a development path?

I'm trying to fix a bug in a more complex PEAR package (CodeCoverage). So I'd like to have the development version that exists not within my PEAR path:
c:\Programme\PHP\PEAR\PHP
with one on another location, here exemplary:
c:\Dokumente und Einstellungen\hakre\PhpstormProjects\php-code-coverage\PHP\
Is there a common way in PEAR to temporarily switch from the installed package to just the files on another location of the disk?
I tried with placing a symbolic link, but that does not work because I need to link CodeCoverage.php as well which is not possible on Windows XP.
Is there some kind of development switch for this kind of scenario in PEAR or is it just that it's the business of each package to take care of that?
I'm using the CodeCoverage package together with PHPUnit.
I could get it to work by adding it to PHP's include path before the PEAR dir:
include_path = ".;c:\path\to\php-code-coverage;C:\programme\php\pear"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Invoking PHPUnit now uses the standard package but the development version of CodeCoverage. No symbolic linking required, editing php.ini is enough.
The "Contributing" section of the PHPUnit github project has a runner script included to make that task easier for you.
You can ether check out all the repositories from there or, if you only need one, still use the runner script:
#!/bin/bash
php -d include_path='.:../phpunit/:../dbunit/:../php-code-coverage/:../php-file-iterator/:../php-invoker/:../php-text-template/:../php-timer:../php-token-stream:../phpunit-mock-objects/:../phpunit-selenium/:../phpunit-story/:/usr/local/lib/php' ../phpunit/phpunit.php $*
(intentially not formatted as code so the whole thing is shown)
You can adapt the pathes to an absolute one by replacing .. with /path/to/your/dev/folder/ and put the script in /usr/local/bin/ and call it phpunit-dev.
Then it will automatically pick up all the existing folders and fall back to the pear path at the end for everything it can't find.
Another way to get a dev setup quickly would be to install it from composer with minimum-stability: dev and change the remote on one of the repos :)

Apply patch file to Magento core files

I edit some core code of magento. After this I would like to patch all my edited files to the Magento directory.
My question is: How can I implement php patch with magento? Or how to create patch file with PHP.
Please help me.
Pathfiles are great way to record & distribute you local modifications. Creating a patch file is relatively easy, and applying a patch is even easier.
Before you begin, how did you retrieve Magento's source file?
If you've checkout the source code with SVN, generating a patch is pretty simple.
shell $> cd path/to/your/working/copy
shell $> svn diff > ~/Desktop/magento.path
However, if you downloaded Magento from an archive (tar,zip), you'll need to have the copy of the original files before comparing your revisions. I like to make a original file backup, cp source.php source.php.org, before I alter anything. Sometimes I forget, and I'll need extract the original source-code to a new directory for comparison. To generate a patch file by comparing two sources, use the diff command
shell $> diff -Naur path/to/original/copy path/to/your/working/copy > ~/Desktop/magento.patch
To apply your newly created patch, use the patch command.
shell $> cd path/to/new/magento
shell $> patch -p0 < ~/Desktop/magento.patch
Piece of cake.
Now your question implied that you may want PHP to apply patches. If you comfortable with compiling PHP extentions, take a look at xdiff's xdiff_file_patch function. Else, simply run the previous commands through PHP's system or shell_exec methods.

Categories