Skip to content

Instantly share code, notes, and snippets.

@ysasaki
Created July 17, 2015 11:38
Show Gist options
  • Save ysasaki/d1c95fe4a80a556eb2f8 to your computer and use it in GitHub Desktop.
Save ysasaki/d1c95fe4a80a556eb2f8 to your computer and use it in GitHub Desktop.
namespace, classを衝突させてみた
% cat composer.json
{
"config": {
"vendor-dir": "vendor"
},
"require": {
"monolog/monolog": "^1.15"
},
"autoload": {
"classmap": [
"lib/"
]
}
}
% cat lib/Monolog/Logger.php
<?php
namespace Monolog;
class Logger
{
public function addInfo($string) {
var_dump($string);
}
} yosasaki@SPC-072
% cat index.php
<?php
require __DIR__.'/vendor/autoload.php';
use Monolog\Logger;
$logger = new Logger('hoge');
$logger->addInfo('hoge’);
% php index.php
string(4) "hoge"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment