PHP code example of siad007 / packagist

1. Go to this page and download the library: Download siad007/packagist library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

siad007 / packagist example snippets



// fetch a list of all vendor-names/package-names (inside a view script)
echo $this->packagist()->fetch();

// will output something like
0x20h/monoconf
11ya/excelbundle
11ya/phpexcel
2085020/api_pingdom
2085020/zendframework1
...

// optional use of an other separator than <br />
echo $this->packagist()->fetch('|');


// Displays a package (inside a view script)
echo $this->packagist()->display('siad007/packagist');

// will output something like
<ul>
    <li>siad007/packagist</li>
        <li>A Zend Framework module using the Packagist API</li>
        <li>zf2, ZendFramework</li>
        <li>1.0.0(1.0.0.0)</li>
        <li>BSD-3-Clause</li>
        <ul>
            <li>Siad Ardroumli, [email protected]</li>
        </ul>
        ...
</ul>


// for a query based search (inside a view script)
echo $this->packagist()->search(array('q' => 'ViewHelper_Packagist'));

// will output something like
<ul id="packagistList">
    <ul class="packagistRow">
        <li class="packagistName">
            <a href="https://packagist.org/packages/siad007/ViewHelper_Packagist">siad007/ViewHelper_Packagist</a>
        </li>
        <li class="packagistDescription">View Helper for Zend Framework 2 using the Packagist API</li>
        <li class="packagistDownloads">123</li>
        <li class="packagistFavors">0</li>
    </ul>
    ...
</ul>

// for a tag based search
echo $this->packagist()->search(array('tags' => 'zf1'));

// for multiple tags
echo $this->packagist()->search(array('tags' => array('zf1', 'view helper')));

// for a tag and query based search
echo $this->packagist()->search(array('q' => 'view helper', 'tags' => 'zf1'));

// or the most 15 popular packages
echo $this->packagist()->search(array('page' => '1', 'q' => ''));