本文整理汇总了PHP中Symfony\Component\Filesystem\Filesystem::mkdir方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::mkdir方法的具体用法?PHP Filesystem::mkdir怎么用?PHP Filesystem::mkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return int|void
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$gitHooksPath = $this->paths()->getGitHooksDir();
$resourceHooksPath = $this->paths()->getGitHookTemplatesDir() . $this->grumPHP->getHooksPreset();
$resourceHooksPath = $this->paths()->getPathWithTrailingSlash($resourceHooksPath);
$customHooksPath = $this->paths()->getPathWithTrailingSlash($this->grumPHP->getHooksDir());
// Some git clients to not automatically create a git hooks folder.
if (!$this->filesystem->exists($gitHooksPath)) {
$this->filesystem->mkdir($gitHooksPath);
$output->writeln(sprintf('<fg=yellow>Created git hooks folder at: %s</fg=yellow>', $gitHooksPath));
}
foreach (self::$hooks as $hook) {
$gitHook = $gitHooksPath . $hook;
$hookTemplate = $resourceHooksPath . $hook;
if ($customHooksPath && $this->filesystem->exists($customHooksPath . $hook)) {
$hookTemplate = $customHooksPath . $hook;
}
if (!$this->filesystem->exists($hookTemplate)) {
throw new \RuntimeException(sprintf('Could not find hook template for %s at %s.', $hook, $hookTemplate));
}
$content = $this->parseHookBody($hook, $hookTemplate);
file_put_contents($gitHook, $content);
$this->filesystem->chmod($gitHook, 0775);
}
$output->writeln('<fg=yellow>Watch out! GrumPHP is sniffing your commits!<fg=yellow>');
}
示例2: save
/**
* {@inheritdoc}
*/
public function save($tempPath, $fileName, $version, $storageOption = null)
{
$this->storageOption = new stdClass();
if ($storageOption) {
$oldStorageOption = json_decode($storageOption);
$segment = $oldStorageOption->segment;
} else {
$segment = sprintf('%0' . strlen($this->segments) . 'd', rand(1, $this->segments));
}
$segmentPath = $this->uploadPath . '/' . $segment;
$fileName = $this->getUniqueFileName($segmentPath, $fileName);
$filePath = $this->getPathByFolderAndFileName($segmentPath, $fileName);
$this->logger->debug('Check FilePath: ' . $filePath);
if (!$this->filesystem->exists($segmentPath)) {
$this->logger->debug('Try Create Folder: ' . $segmentPath);
$this->filesystem->mkdir($segmentPath, 0777);
}
$this->logger->debug('Try to copy File "' . $tempPath . '" to "' . $filePath . '"');
if ($this->filesystem->exists($filePath)) {
throw new FilenameAlreadyExistsException($filePath);
}
$this->filesystem->copy($tempPath, $filePath);
$this->addStorageOption('segment', $segment);
$this->addStorageOption('fileName', $fileName);
return json_encode($this->storageOption);
}
示例3: setUp
public function setUp()
{
$this->numberOfPayloads = 5;
$this->tempDirectory = sys_get_temp_dir() . '/orphanage';
$this->realDirectory = sys_get_temp_dir() . '/storage';
$this->payloads = array();
$filesystem = new Filesystem();
$filesystem->mkdir($this->tempDirectory);
$filesystem->mkdir($this->realDirectory);
for ($i = 0; $i < $this->numberOfPayloads; $i++) {
// create temporary file
$file = tempnam(sys_get_temp_dir(), 'uploader');
$pointer = fopen($file, 'w+');
fwrite($pointer, str_repeat('A', 1024), 1024);
fclose($pointer);
$this->payloads[] = new FilesystemFile(new UploadedFile($file, $i . 'grumpycat.jpeg', null, null, null, true));
}
// create underlying storage
$this->storage = new FilesystemStorage($this->realDirectory);
// is ignored anyways
$chunkStorage = new FilesystemChunkStorage('/tmp/');
// create orphanage
$session = new Session(new MockArraySessionStorage());
$session->start();
$config = array('directory' => $this->tempDirectory);
$this->orphanage = new FilesystemOrphanageStorage($this->storage, $session, $chunkStorage, $config, 'cat');
}
示例4: __construct
/**
* @param string $repository
* @param PriorityHandlerInterface $priorityHandler
* @param Filesystem $fs
* @param Finder $finder
* @param LockHandlerFactoryInterface $lockHandlerFactory
*/
public function __construct($repository, PriorityHandlerInterface $priorityHandler = null, Filesystem $fs = null, Finder $finder = null, LockHandlerFactoryInterface $lockHandlerFactory = null)
{
if (empty($repository)) {
throw new InvalidArgumentException('Argument repository empty or not defined.');
}
if (null === $fs) {
$fs = new Filesystem();
}
if (null === $finder) {
$finder = new Finder();
}
if (null === $lockHandlerFactory) {
$lockHandlerFactory = new LockHandlerFactory();
}
if (null === $priorityHandler) {
$priorityHandler = new StandardPriorityHandler();
}
$this->fs = $fs;
if (!$this->fs->exists($repository)) {
try {
$this->fs->mkdir($repository);
} catch (IOExceptionInterface $e) {
throw new InvalidArgumentException('An error occurred while creating your directory at ' . $e->getPath());
}
}
$this->priorityHandler = $priorityHandler;
$this->repository = $repository;
$this->finder = $finder;
$this->finder->files()->in($repository);
$this->lockHandlerFactory = $lockHandlerFactory;
return $this;
}
示例5: onSettingUpSite
/**
* @param SiteEvent $event
*/
public function onSettingUpSite(SiteEvent $event)
{
$drupal = $event->getDrupal();
$this->eventDispatcher->dispatch(WritingSiteSettingsFile::NAME, $settings = new WritingSiteSettingsFile($drupal));
$this->filesystem->mkdir($drupal->getSitePath());
file_put_contents($drupal->getSitePath() . '/settings.php', '<?php ' . $settings->getSettings());
}
示例6: setUp
protected function setUp()
{
$this->filesystem = new Filesystem();
$this->linksDirectory = sys_get_temp_dir() . '/' . uniqid() . '/links/';
$this->filesystem->mkdir($this->linksDirectory);
$this->importer = new DocumentationRootImporter($this->linksDirectory, $this->filesystem);
}
开发者ID:matthiasnoback,项目名称:sphinx-documentation-collector,代码行数:7,代码来源:DocumentationRootImporterTest.php
示例7: createRequiredFiles
public static function createRequiredFiles(Event $event)
{
$fs = new Filesystem();
$root = static::getDrupalRoot(getcwd());
$dirs = ['modules', 'profiles', 'themes'];
// Required for unit testing
foreach ($dirs as $dir) {
if (!$fs->exists($root . '/' . $dir)) {
$fs->mkdir($root . '/' . $dir);
$fs->touch($root . '/' . $dir . '/.gitkeep');
}
}
// Prepare the settings file for installation
if (!$fs->exists($root . '/sites/default/settings.php')) {
$fs->copy($root . '/sites/default/default.settings.php', $root . '/sites/default/settings.php');
$fs->chmod($root . '/sites/default/settings.php', 0666);
$event->getIO()->write("Create a sites/default/settings.php file with chmod 0666");
}
// Prepare the services file for installation
if (!$fs->exists($root . '/sites/default/services.yml')) {
$fs->copy($root . '/sites/default/default.services.yml', $root . '/sites/default/services.yml');
$fs->chmod($root . '/sites/default/services.yml', 0666);
$event->getIO()->write("Create a sites/default/services.yml file with chmod 0666");
}
// Create the files directory with chmod 0777
if (!$fs->exists($root . '/sites/default/files')) {
$oldmask = umask(0);
$fs->mkdir($root . '/sites/default/files', 0777);
umask($oldmask);
$event->getIO()->write("Create a sites/default/files directory with chmod 0777");
}
}
示例8: setUp
protected function setUp()
{
$this->directory = sys_get_temp_dir() . '/AbstractBundleReaderTest/' . rand(1000, 9999);
$this->filesystem = new Filesystem();
$this->reader = $this->getMockForAbstractClass('Symfony\\Component\\Intl\\ResourceBundle\\Reader\\AbstractBundleReader');
$this->filesystem->mkdir($this->directory);
}
示例9: setWorkingDirectory
private function setWorkingDirectory()
{
$this->workingDirectory = tempnam(sys_get_temp_dir(), 'phpzone-test');
$this->filesystem->remove($this->workingDirectory);
$this->filesystem->mkdir($this->workingDirectory);
chdir($this->workingDirectory);
}
示例10: let
function let(ColumnSorterInterface $columnSorter)
{
$this->directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'spec' . DIRECTORY_SEPARATOR;
$this->filesystem = new Filesystem();
$this->filesystem->mkdir($this->directory);
$this->beConstructedWith($columnSorter);
}
示例11: dump
/**
* @param string $langPackDir language pack dir in temp folder
* @param string $projectNamespace e.g. Oro, OroCRM, etc
* @param string $outputFormat xml, yml, etc
* @param string $locale en, en_US, fr, etc
*/
public function dump($langPackDir, $projectNamespace, $outputFormat, $locale)
{
$this->preloadExistingTranslations($locale);
foreach ($this->bundles as $bundle) {
// skip bundles from other projects
if ($projectNamespace != $this->getBundlePrefix($bundle->getNamespace())) {
continue;
}
$this->logger->log(LogLevel::INFO, '');
$this->logger->log(LogLevel::INFO, sprintf('Writing files for <info>%s</info>', $bundle->getName()));
/** @var MessageCatalogue $currentCatalogue */
$currentCatalogue = $this->getCurrentCatalog($locale, $bundle->getName());
$extractedCatalogue = $this->extractViewTranslationKeys($locale, $bundle->getPath());
$operation = new MergeOperation($currentCatalogue, $extractedCatalogue);
$messageCatalogue = $operation->getResult();
$isEmptyCatalogue = $this->validateAndFilter($messageCatalogue);
if (!$isEmptyCatalogue) {
$translationsDir = $langPackDir . DIRECTORY_SEPARATOR . $bundle->getName() . DIRECTORY_SEPARATOR . 'translations';
$this->filesystem->mkdir($translationsDir);
$this->writer->writeTranslations($messageCatalogue, $outputFormat, ['path' => $translationsDir]);
} else {
$this->logger->log(LogLevel::INFO, ' - no files generated');
}
}
}
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
$fs = new Filesystem();
$fs->mkdir(InterfaceTest::PATH);
if (!is_writable(InterfaceTest::PATH)) {
$this->markTestSkipped('There are no write permissions in order to create test repositories.');
}
$options['path'] = getenv('GIT_CLIENT') ?: '/usr/bin/git';
$options['hidden'] = array(InterfaceTest::PATH . '/hiddenrepo');
$git = new Client($options);
// GitTest repository fixture
$git->createRepository(InterfaceTest::PATH . 'GitTest');
$repository = $git->getRepository(InterfaceTest::PATH . 'GitTest');
file_put_contents(InterfaceTest::PATH . 'GitTest/README.md', "## GitTest\nGitTest is a *test* repository!");
file_put_contents(InterfaceTest::PATH . 'GitTest/test.php', "<?php\necho 'Hello World'; // This is a test");
$repository->setConfig('user.name', 'Luke Skywalker');
$repository->setConfig('user.email', 'luke@rebel.org');
$repository->addAll();
$repository->commit("Initial commit");
$repository->createBranch('issue12');
$repository->createBranch('issue42');
// foobar repository fixture
$git->createRepository(InterfaceTest::PATH . 'foobar');
$repository = $git->getRepository(InterfaceTest::PATH . '/foobar');
file_put_contents(InterfaceTest::PATH . 'foobar/bar.json', "{\n\"name\": \"foobar\"\n}");
file_put_contents(InterfaceTest::PATH . 'foobar/.git/description', 'This is a test repo!');
$fs->mkdir(InterfaceTest::PATH . 'foobar/myfolder');
$fs->mkdir(InterfaceTest::PATH . 'foobar/testfolder');
file_put_contents(InterfaceTest::PATH . 'foobar/myfolder/mytest.php', "<?php\necho 'Hello World'; // This is my test");
file_put_contents(InterfaceTest::PATH . 'foobar/testfolder/test.php', "<?php\necho 'Hello World'; // This is a test");
$repository->setConfig('user.name', 'Luke Skywalker');
$repository->setConfig('user.email', 'luke@rebel.org');
$repository->addAll();
$repository->commit("First commit");
}
示例13: createDirectory
/**
* create directory.
*
* @param $path
*
* @throws \Exception
*
* @return bool
*/
public function createDirectory($path)
{
if (!$this->exists(realpath($path))) {
$res = $this->fs->mkdir($path);
}
return true;
}
示例14: generate
/**
* @param $path
* @throws \Exception
*/
public function generate($path)
{
if ($this->filesystem->exists($path)) {
throw new \Exception("Error module already exists");
}
$this->filesystem->mkdir($path, 0700);
}
示例15: execute
/**
* {@inheritdoc}
*
* @see \Symfony\Component\Console\Command\Command::execute()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$assets = $this->getContainer()->getParameter('asf_layout.assets');
$this->tinymce_config = $assets['tinymce'];
$dest_dir = $input->getArgument('target_dir') ? $input->getArgument('target_dir') : null;
if (is_null($dest_dir) && isset($this->tinymce_config['customize']['dest_dir'])) {
$dest_dir = $this->tinymce_config['customize']['dest_dir'];
}
$exclude_files = $input->getOption('exclude_files') ? $input->getOption('exclude_files') : $this->tinymce_config['customize']['exclude_files'];
$src_dir = sprintf('%s', $this->tinymce_config['tinymce_dir']);
$fs = new Filesystem();
try {
if (!$fs->exists($dest_dir)) {
$fs->mkdir($dest_dir);
}
} catch (IOException $e) {
$output->writeln(sprintf('<error>Could not create directory %s.</error>', $dest_dir));
return;
}
if (false === file_exists($src_dir)) {
$output->writeln(sprintf('<error>Source directory "%s" does not exist. Did you install TinyMCE ? ' . 'Don\'t forget to specify the path to TinyMCE folder in ' . '"asf_layout.assets.tinymce.tinymce_dir".</error>', $src_dir));
return;
}
foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($src_dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) {
if ($item->isDir() && !in_array($item->getBasename(), $exclude_files)) {
$fs->mkdir($dest_dir . '/' . $iterator->getSubPathName());
} elseif (!in_array($item->getBasename(), $exclude_files)) {
$fs->copy($item, $dest_dir . '/' . $iterator->getSubPathName());
}
}
$output->writeln(sprintf('[OK] TinyMCE files was successfully copied in "%s".', $dest_dir));
}