本文整理匯總了PHP中Composer\Script\Event::getIo方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::getIo方法的具體用法?PHP Event::getIo怎麽用?PHP Event::getIo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Script\Event
的用法示例。
在下文中一共展示了Event::getIo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: changeThemeName
public static function changeThemeName(Event $event)
{
$installer = new Installer($event->getIo());
if ($installer->doChangeThemeName()) {
$installer->getIo()->write(' * Running `composer update`');
exec('composer update');
}
}
示例2: registerPackage
/**
* On Composer's "post-package-install" event, register the package.
*
* @param Event $event
*/
public function registerPackage(Event $event)
{
$output = $event->getIo();
$installedPackage = $event->getOperation()->getPackage();
if (!$this->supports($installedPackage)) {
return;
}
try {
$this->enablePackage($installedPackage);
} catch (\RuntimeException $e) {
$output->write(sprintf('Bundle "%s" is already registered', $installedPackage));
}
}
示例3: setUp
private static function setUp(Event $event)
{
$dir = dirname(__DIR__);
$commands = array("chmod -R 777 {$dir}/logs/", "chmod -R 777 {$dir}/tmp/");
foreach ($commands as $cmd) {
$event->getIo()->write('<info>' . $cmd . '</info>');
passthru($cmd, $retval);
}
if (!file_exists("{$dir}/htdocs/htaccess.txt")) {
return;
}
$htaccess = "{$dir}/htdocs/.htaccess";
rename("{$dir}/htdocs/htaccess.txt", $htaccess);
$contents = file_get_contents($htaccess);
$contents = str_replace('@APP-DIR@', "{$dir}", $contents);
file_put_contents($htaccess, $contents);
}
示例4: postInstall
/**
* This method will be invoked by composer after a successfull installation and creates
* the application server configuration file under etc/appserver/appserver.xml.
*
* @param \Composer\Script\Event $event The event that invokes this method
*
* @return void
*/
public static function postInstall(Event $event)
{
// load the version of this package => the appserver version
$version = $event->getComposer()->getPackage()->getVersion();
// prepare the context properties
$contextProperties = array(SetupKeys::INSTALL_DIR => getcwd(), SetupKeys::VERSION => $version);
// load the OS signature => sscanf is necessary to detect Windows, e. g. Windows NT for Windows 7
list($os, ) = sscanf(strtolower(php_uname('s')), '%s %s');
// check what OS we are running on
switch ($os) {
// installation running on Linux
case SetupKeys::OS_FAMILY_LINUX:
// get the distribution
$distribution = Setup::getLinuxDistro();
if ($distribution == null) {
// if we cant find one of the supported systems
// set debian as default
$distribution = SetupKeys::OS_DEBIAN;
// write a message to the console
$event->getIo()->write(sprintf('<warning>Unknown Linux distribution found, use Debian default values: ' . 'Please check user/group configuration in etc/appserver/appserver.xml</warning>'));
}
// merge the properties for the found Linux distribution
Setup::prepareProperties($distribution, $contextProperties);
// process the binaries for the systemd services on Fedora
if ($distribution === SetupKeys::OS_FEDORA || $distribution === SetupKeys::OS_REDHAT) {
Setup::processTemplate('bin/appserver', 0755);
Setup::processTemplate('bin/appserver-watcher', 0755);
}
break;
// installation running on Mac OS X
// installation running on Mac OS X
case SetupKeys::OS_FAMILY_DARWIN:
// merge the properties for Mac OS X
Setup::prepareProperties($os, $contextProperties);
// process the control files for the launchctl service
Setup::processOsSpecificTemplate(SetupKeys::OS_DARWIN, 'sbin/appserverctl', 0755);
Setup::processOsSpecificTemplate(SetupKeys::OS_DARWIN, 'sbin/appserver-watcherctl', 0755);
Setup::processOsSpecificTemplate(SetupKeys::OS_DARWIN, 'sbin/appserver-php5-fpmctl', 0755);
Setup::processOsSpecificTemplate(SetupKeys::OS_DARWIN, 'sbin/plist/io.appserver.appserver.plist');
Setup::processOsSpecificTemplate(SetupKeys::OS_DARWIN, 'sbin/plist/io.appserver.appserver-watcher.plist');
Setup::processOsSpecificTemplate(SetupKeys::OS_DARWIN, 'sbin/plist/io.appserver.appserver-php5-fpm.plist');
// process the binaries for the launchctl service
Setup::processTemplate('bin/appserver', 0755);
Setup::processTemplate('bin/appserver-watcher', 0755);
break;
// installation running on Windows
// installation running on Windows
case SetupKeys::OS_FAMILY_WINDOWS:
// merge the properties for Windows
Setup::prepareProperties($os, $contextProperties);
// process the control files for the launchctl service
Setup::copyOsSpecificResource(SetupKeys::OS_WINDOWS, 'appserver.bat');
Setup::processOsSpecificTemplate(SetupKeys::OS_WINDOWS, 'appserver-php5-fpm.bat');
break;
// all other OS are NOT supported actually
// all other OS are NOT supported actually
default:
break;
}
// process and move the configuration files their target directory
Setup::processTemplate('var/tmp/opcache-blacklist.txt');
Setup::processTemplate('etc/appserver/appserver.xml');
// write a message to the console
$event->getIo()->write(sprintf('%s<info>Successfully invoked appserver.io Composer post-install-cmd script ...</info>', Setup::$logo));
}