user38095: I need some PHP code to generate bitcoin addresses from a given public key.
I can only find algorithms to generate addresses from the master private key but according to https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses
the private key is not required at all.

user49580: Full instruction based on response of @Farghaly: Ubuntu 16
Install dependencies
sudo apt-get install php-bcmath php-gmp
composer require bitwasp/bitcoin

And then in fiel app.php
<?php
require 'vendor/autoload.php';

use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Address;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;

$network = Bitcoin::getNetwork();

$privateKey = PrivateKeyFactory::create(true);
$publicKey = $privateKey->getPublicKey();
$address = $publicKey->getAddress();


user12049: Use BitWasp Bitcoin-php library
https://github.com/Bit-Wasp/bitcoin-php
<?php
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;

$network = Bitcoin::getNetwork();
$privateKey = PrivateKeyFactory::create(true);
$publicKey = $privateKey->getPublicKey();
$address = $publicKey->getAddress(); // returns AddressInterface
echo $address->getAddress($network); // prints address for $network as string

If you want to create Bitcoin address from Public key string check documentation for Factory classes
or newer versions:
<?php
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Address\AddressCreator;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;
use BitWasp\Bitcoin\Key\KeyToScript\Factory\P2pkhScriptDataFactory; 

$network = Bitcoin::getNetwork();
$privateKey = PrivateKeyFactory::create(true);
$publicKey = $privateKey->getPublicKey();

$addrCreator = new AddressCreator();
$factory = new P2pkhScriptDataFactory();
$scriptPubKey = $factory->convertKey($publicKey)->getScriptPubKey();
$address = $addrCreator->fromOutputScript($scriptPubKey); // returns AddressInterface
echo $address->getAddress($network); // prints address for $network as string


38095: <p>I need some PHP code to generate bitcoin addresses from a given public key.</p>

<p>I can only find algorithms to generate addresses from the master private key but according to <a href="https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses" rel="noreferrer">https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses</a>
the private key is not required at all.</p>
 49580: <p>Full instruction based on response of @Farghaly: <strong>Ubuntu 16</strong></p>

<p>Install dependencies</p>

<pre><code>sudo apt-get install php-bcmath php-gmp
composer require bitwasp/bitcoin
</code></pre>

<p>And then in fiel <code>app.php</code></p>

<pre><code>&lt;?php
require 'vendor/autoload.php';

use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Address;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;

$network = Bitcoin::getNetwork();

$privateKey = PrivateKeyFactory::create(true);
$publicKey = $privateKey-&gt;getPublicKey();
$address = $publicKey-&gt;getAddress();
</code></pre>
 12049: <p>Use BitWasp Bitcoin-php library
<a href="https://github.com/Bit-Wasp/bitcoin-php" rel="nofollow noreferrer">https://github.com/Bit-Wasp/bitcoin-php</a></p>

<pre><code>&lt;?php
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;

$network = Bitcoin::getNetwork();
$privateKey = PrivateKeyFactory::create(true);
$publicKey = $privateKey-&gt;getPublicKey();
$address = $publicKey-&gt;getAddress(); // returns AddressInterface
echo $address-&gt;getAddress($network); // prints address for $network as string
</code></pre>

<p>If you want to create Bitcoin address from Public key string <a href="https://github.com/Bit-Wasp/bitcoin-php/tree/master/doc" rel="nofollow noreferrer">check documentation</a> for <strong>Factory classes</strong></p>

<p>or newer versions:</p>

<pre><code>&lt;?php
use BitWasp\Bitcoin\Bitcoin;
use BitWasp\Bitcoin\Address\AddressCreator;
use BitWasp\Bitcoin\Key\PrivateKeyFactory;
use BitWasp\Bitcoin\Key\KeyToScript\Factory\P2pkhScriptDataFactory; 

$network = Bitcoin::getNetwork();
$privateKey = PrivateKeyFactory::create(true);
$publicKey = $privateKey-&gt;getPublicKey();

$addrCreator = new AddressCreator();
$factory = new P2pkhScriptDataFactory();
$scriptPubKey = $factory-&gt;convertKey($publicKey)-&gt;getScriptPubKey();
$address = $addrCreator-&gt;fromOutputScript($scriptPubKey); // returns AddressInterface
echo $address-&gt;getAddress($network); // prints address for $network as string
</code></pre>
