当前位置: 首页>>代码示例>>PHP>>正文


PHP Package::setAutoload方法代码示例

本文整理汇总了PHP中Composer\Package\Package::setAutoload方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::setAutoload方法的具体用法?PHP Package::setAutoload怎么用?PHP Package::setAutoload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Package\Package的用法示例。


在下文中一共展示了Package::setAutoload方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createPackage

 /**
  * @param string $type
  * @param string $targetDir
  * @param array $autoload
  * @return \Composer\Package\Package
  */
 protected function createPackage($name, $type, array $autoload)
 {
     $package = new Package($name, 'dev-master', '9999999-dev');
     $package->setType($type);
     $package->setAutoload($autoload);
     return $package;
 }
开发者ID:frogriotcom,项目名称:CheckBundles,代码行数:13,代码来源:ComposerHelperTest.php

示例2: getInstalledPackages

 public function getInstalledPackages()
 {
     $fooPackage = new Package('acme/foo-bundle', 'dev-master', '9999999-dev');
     $fooPackage->setAutoload(array('psr-0' => array('Acme\\FooBundle' => '')));
     $fooPackage->setType('symfony-bundle');
     $barPackage = new Package('acme/bar-bundle', 'dev-master', '9999999-dev');
     $barPackage->setAutoload(array('psr-0' => array('Acme\\BarBundle' => 'src/')));
     $barPackage->setType('symfony-bundle');
     $fooBarPackage = new Package('acme/foobar-bundle', 'dev-master', '9999999-dev');
     $fooBarPackage->setAutoload(array('psr-4' => array('Acme\\FooBarBundle\\' => '')));
     $fooBarPackage->setType('symfony-bundle');
     return array($fooPackage, $barPackage, $fooBarPackage);
 }
开发者ID:frogriotcom,项目名称:CheckBundles,代码行数:13,代码来源:ComposerTestCase.php

示例3: resolvePackageDependencies

 private function resolvePackageDependencies($repository, $packages, $packageName)
 {
     $config = $packages[$packageName];
     foreach ($config['deps'] as $dependencyName) {
         if ($dependencyName === 'vendor/php' || strpos($dependencyName, 'vendor/ext-') === 0 || strpos($dependencyName, 'vendor/lib-') === 0) {
             continue;
         }
         if (!isset($packages[$dependencyName])) {
             throw new \RuntimeException("Requiring non existant package '" . $dependencyName . "' in '" . $packageName . "'.");
         }
         $dependency = $packages[$dependencyName];
         $package = new Package($dependency['path'], "@stable", "@stable");
         $package->setType('fiddler');
         if (isset($dependency['autoload']) && is_array($dependency['autoload'])) {
             $package->setAutoload($dependency['autoload']);
         }
         if (!$repository->hasPackage($package)) {
             $repository->addPackage($package);
             $this->resolvePackageDependencies($repository, $packages, $dependencyName);
         }
     }
 }
开发者ID:sidisinsane,项目名称:fiddler,代码行数:22,代码来源:Build.php

示例4: testTypo3Inflection

 /**
  * testTypo3Inflection
  */
 public function testTypo3Inflection()
 {
     $installer = new Installer($this->io, $this->composer);
     $package = new Package('typo3/fluid', '1.0.0', '1.0.0');
     $package->setAutoload(array('psr-0' => array('TYPO3\\Fluid' => 'Classes')));
     $package->setType('typo3-flow-package');
     $result = $installer->getInstallPath($package);
     $this->assertEquals('Packages/Application/TYPO3.Fluid/', $result);
 }
开发者ID:eacquah,项目名称:lolgh,代码行数:12,代码来源:InstallerTest.php

示例5: testDeterminePlugins

 public function testDeterminePlugins()
 {
     $plugin1 = new Package('cakephp/the-thing', '1.0', '1.0');
     $plugin1->setType('cakephp-plugin');
     $plugin1->setAutoload(['psr-4' => ['TheThing' => 'src/']]);
     $plugin2 = new Package('cakephp/princess', '1.0', '1.0');
     $plugin2->setType('cakephp-plugin');
     $plugin2->setAutoload(['psr-4' => ['Princess' => 'src/']]);
     $packages = [$plugin1, new Package('SomethingElse', '1.0', '1.0'), $plugin2];
     $return = PluginInstaller::determinePlugins($packages, $this->path . '/doesnt-exist', $this->path . '/vendor');
     $expected = ['Princess' => $this->path . '/vendor/cakephp/princess', 'TheThing' => $this->path . '/vendor/cakephp/the-thing'];
     $this->assertSame($expected, $return, 'Only composer-loaded plugins should be listed');
     $return = PluginInstaller::determinePlugins($packages, $this->path . '/plugins', $this->path . '/vendor');
     $expected = ['Fee' => $this->path . '/plugins/Fee', 'Foe' => $this->path . '/plugins/Foe', 'Foo' => $this->path . '/plugins/Foo', 'Fum' => $this->path . '/plugins/Fum', 'Princess' => $this->path . '/vendor/cakephp/princess', 'TheThing' => $this->path . '/vendor/cakephp/the-thing'];
     $this->assertSame($expected, $return, 'Composer and application plugins should be listed');
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:16,代码来源:PluginInstallerTest.php

示例6: resolvePackageDependencies

 private function resolvePackageDependencies($repository, $packages, $packageName)
 {
     $config = $packages[$packageName];
     $dependencies = $config['deps'];
     if (isset($config['deps-dev'])) {
         $dependencies = array_merge($dependencies, $config['deps-dev']);
     }
     foreach ($dependencies as $dependencyName) {
         $isVendor = strpos($dependencyName, 'vendor/') === 0;
         if ($dependencyName === 'vendor/php' || strpos($dependencyName, 'vendor/ext-') === 0 || strpos($dependencyName, 'vendor/lib-') === 0) {
             continue;
             // Meta-dependencies that composer checks
         }
         if (!isset($packages[$dependencyName])) {
             if ($dependencyName == 'vendor/composer-plugin-api') {
                 continue;
             }
             if ($isVendor) {
                 throw new \RuntimeException("Requiring non-existent composer-package '" . $dependencyName . "' in '" . $packageName . "'. Please ensure it is present in composer.json.");
             } else {
                 throw new \RuntimeException("Requiring non-existent repo-module '" . $dependencyName . "' in '" . $packageName . "'. Please check that the subdirectory exists, or append \"vendor/\" to reference a composer-package.");
             }
         }
         $dependency = $packages[$dependencyName];
         $package = new Package($dependency['path'], "@stable", "@stable");
         $package->setType('monorepo');
         if (isset($dependency['autoload']) && is_array($dependency['autoload'])) {
             $package->setAutoload($dependency['autoload']);
         }
         if (isset($dependency['bin']) && is_array($dependency['bin'])) {
             $package->setBinaries($dependency['bin']);
         }
         if (!$repository->hasPackage($package)) {
             $repository->addPackage($package);
             $this->resolvePackageDependencies($repository, $packages, $dependencyName);
         }
     }
 }
开发者ID:beberlei,项目名称:composer-monorepo-plugin,代码行数:38,代码来源:Build.php

示例7: testExcludeFromClassmap

 public function testExcludeFromClassmap()
 {
     $package = new Package('a', '1.0', '1.0');
     $package->setAutoload(array('psr-0' => array('Main' => 'src/', 'Lala' => array('src/', 'lib/')), 'psr-4' => array('Acme\\Fruit\\' => 'src-fruit/', 'Acme\\Cake\\' => array('src-cake/', 'lib-cake/')), 'classmap' => array('composersrc/'), 'exclude-from-classmap' => array('/composersrc/excludedTests/', '/composersrc/ClassToExclude.php', '/composersrc/*/excluded/excsubpath', '**/excsubpath')));
     $this->repository->expects($this->once())->method('getCanonicalPackages')->will($this->returnValue(array()));
     $this->fs->ensureDirectoryExists($this->workingDir . '/composer');
     $this->fs->ensureDirectoryExists($this->workingDir . '/src/Lala/Test');
     $this->fs->ensureDirectoryExists($this->workingDir . '/lib');
     file_put_contents($this->workingDir . '/src/Lala/ClassMapMain.php', '<?php namespace Lala; class ClassMapMain {}');
     file_put_contents($this->workingDir . '/src/Lala/Test/ClassMapMainTest.php', '<?php namespace Lala\\Test; class ClassMapMainTest {}');
     $this->fs->ensureDirectoryExists($this->workingDir . '/src-fruit');
     $this->fs->ensureDirectoryExists($this->workingDir . '/src-cake');
     $this->fs->ensureDirectoryExists($this->workingDir . '/lib-cake');
     file_put_contents($this->workingDir . '/src-cake/ClassMapBar.php', '<?php namespace Acme\\Cake; class ClassMapBar {}');
     $this->fs->ensureDirectoryExists($this->workingDir . '/composersrc');
     $this->fs->ensureDirectoryExists($this->workingDir . '/composersrc/tests');
     file_put_contents($this->workingDir . '/composersrc/foo.php', '<?php class ClassMapFoo {}');
     // this classes should not be found in the classmap
     $this->fs->ensureDirectoryExists($this->workingDir . '/composersrc/excludedTests');
     file_put_contents($this->workingDir . '/composersrc/excludedTests/bar.php', '<?php class ClassExcludeMapFoo {}');
     file_put_contents($this->workingDir . '/composersrc/ClassToExclude.php', '<?php class ClassClassToExclude {}');
     $this->fs->ensureDirectoryExists($this->workingDir . '/composersrc/long/excluded/excsubpath');
     file_put_contents($this->workingDir . '/composersrc/long/excluded/excsubpath/foo.php', '<?php class ClassExcludeMapFoo2 {}');
     file_put_contents($this->workingDir . '/composersrc/long/excluded/excsubpath/bar.php', '<?php class ClassExcludeMapBar {}');
     $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_1');
     // Assert that autoload_classmap.php was correctly generated.
     $this->assertAutoloadFiles('classmap', $this->vendorDir . '/composer', 'classmap');
 }
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-composer,代码行数:28,代码来源:AutoloadGeneratorTest.php

示例8: testVendorSubstringPath

    public function testVendorSubstringPath()
    {
        $package = new Package('a', '1.0', '1.0');
        $package->setAutoload(array('psr-0' => array('Foo' => 'composer-test-autoload-src/src'), 'psr-4' => array('Acme\\Foo\\' => 'composer-test-autoload-src/src-psr4')));
        $this->repository->expects($this->once())->method('getCanonicalPackages')->will($this->returnValue(array()));
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a');
        $expectedNamespace = <<<'EOF'
<?php

// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Foo' => array($baseDir . '/composer-test-autoload-src/src'),
);

EOF;
        $expectedPsr4 = <<<'EOF'
<?php

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Acme\\Foo\\' => array($baseDir . '/composer-test-autoload-src/src-psr4'),
);

EOF;
        $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, 'VendorSubstring');
        $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir . '/composer/autoload_namespaces.php'));
        $this->assertEquals($expectedPsr4, file_get_contents($this->vendorDir . '/composer/autoload_psr4.php'));
    }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:36,代码来源:AutoloadGeneratorTest.php

示例9: createPackage

 public function createPackage($name, $ns, $type = 'symfony-bundle')
 {
     $package = new Package($name, '1.0.0', '1.0.0');
     $package->setType($type);
     $package->setAutoload(['psr-4' => [$ns => '']]);
     return $package;
 }
开发者ID:fuzzyma,项目名称:composer-register-bundle-plugin,代码行数:7,代码来源:RegisterCommandTest.php

示例10: testOverrideVendorsAutoloading

    public function testOverrideVendorsAutoloading()
    {
        $package = new Package('a', '1.0', '1.0');
        $package->setAutoload(array('psr-0' => array('A\\B' => $this->workingDir . '/lib')));
        $packages = array();
        $packages[] = $a = new Package('a/a', '1.0', '1.0');
        $packages[] = $b = new Package('b/b', '1.0', '1.0');
        $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/')));
        $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/')));
        $this->repository->expects($this->once())->method('getPackages')->will($this->returnValue($packages));
        $this->fs->ensureDirectoryExists($this->workingDir . '/lib/A/B');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/composer');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a/a/src');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/a/a/lib/A/B');
        $this->fs->ensureDirectoryExists($this->vendorDir . '/b/b/src');
        file_put_contents($this->workingDir . '/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
        file_put_contents($this->vendorDir . '/a/a/lib/A/B/C.php', '<?php namespace A\\B; class C {}');
        $workDir = strtr($this->workingDir, '\\', '/');
        $expectedNamespace = <<<EOF
<?php

// autoload_namespaces.php generated by Composer

\$vendorDir = dirname(__DIR__);
\$baseDir = dirname(\$vendorDir);

return array(
    'B\\\\Sub\\\\Name' => \$vendorDir . '/b/b/src/',
    'A\\\\B' => array('{$workDir}/lib', \$vendorDir . '/a/a/lib/'),
    'A' => \$vendorDir . '/a/a/src/',
);

EOF;
        $expectedClassmap = <<<EOF
<?php

// autoload_classmap.php generated by Composer

\$vendorDir = dirname(__DIR__);
\$baseDir = dirname(\$vendorDir);

return array(
    'A\\\\B\\\\C' => \$baseDir . '/lib/A/B/C.php',
);

EOF;
        $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_9');
        $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir . '/composer/autoload_namespaces.php'));
        $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir . '/composer/autoload_classmap.php'));
    }
开发者ID:rufinus,项目名称:composer,代码行数:50,代码来源:AutoloadGeneratorTest.php

示例11: testEmptyPaths

    public function testEmptyPaths()
    {
        $package = new Package('a', '1.0', '1.0');
        $package->setAutoload(array('psr-0' => array('Foo' => ''), 'classmap' => array('')));
        $this->repository->expects($this->once())->method('getPackages')->will($this->returnValue(array()));
        $this->fs->ensureDirectoryExists($this->workingDir . '/Foo');
        file_put_contents($this->workingDir . '/Foo/Bar.php', '<?php namespace Foo; class Bar {}');
        file_put_contents($this->workingDir . '/class.php', '<?php namespace Classmap; class Foo {}');
        $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', true, '_15');
        $expectedNamespace = <<<'EOF'
<?php

// autoload_namespaces.php generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Foo' => $baseDir . '/',
);

EOF;
        $expectedClassmap = <<<'EOF'
<?php

// autoload_classmap.php generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Classmap\\Foo' => $baseDir . '/class.php',
    'Foo\\Bar' => $baseDir . '/Foo/Bar.php',
);

EOF;
        $this->assertEquals($expectedNamespace, file_get_contents($this->vendorDir . '/composer/autoload_namespaces.php'));
        $this->assertEquals($expectedClassmap, file_get_contents($this->vendorDir . '/composer/autoload_classmap.php'));
    }
开发者ID:robywan,项目名称:composer,代码行数:39,代码来源:AutoloadGeneratorTest.php


注:本文中的Composer\Package\Package::setAutoload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。