def test_validate_php_ini_extensions_when_extension_not_available_and_listed_in_section(self, supported_func, compiled_func):
     ctx = {
         'BUILD_DIR': self.build_dir
     }
     self.setup_php_ini_dir("[php]\nextension =pumpkin.so\nextension=blueberry.so\nextension=pie.so")
     with assert_raises_regexp(RuntimeError, "The extension 'blueberry' is not provided by this buildpack."):
         validate_php_ini_extensions(ctx)
示例#2
0
 def test_validate_php_ini_extensions_when_extension_not_available_and_listed_in_section(self, supported_func, compiled_func):
     ctx = {
         'BUILD_DIR': self.build_dir
     }
     self.setup_php_ini_dir("[php]\nextension =pumpkin.so\nextension=blueberry.so\nextension=pie.so")
     with assert_raises_regexp(RuntimeError, "The extension 'blueberry' is not provided by this buildpack."):
         validate_php_ini_extensions(ctx)
示例#3
0
 def test_validate_php_ini_extensions_when_redis_and_igbinary_are_present(self, supported_func, compiled_func):
     ctx = {
         'BUILD_DIR': self.build_dir,
         'PHP_EXTENSIONS': [],
     }
     self.setup_php_ini_dir("extension=redis.so\nextension=igbinary.so")
     validate_php_ini_extensions(ctx)
     eq_([],
         ctx['PHP_EXTENSIONS'])
示例#4
0
 def test_validate_php_ini_extensions_when_redis_is_specified_without_igbinary(self, supported_func, compiled_func):
     ctx = {
         'BUILD_DIR': self.build_dir,
         'PHP_EXTENSIONS': [],
     }
     self.setup_php_ini_dir("extension=redis.so")
     validate_php_ini_extensions(ctx)
     eq_(['igbinary'],
         ctx['PHP_EXTENSIONS'])
示例#5
0
 def test_validate_php_ini_extensions_when_redis_and_igbinary_are_present(
         self, supported_func, compiled_func):
     ctx = {
         'BUILD_DIR': self.build_dir,
         'PHP_EXTENSIONS': [],
     }
     self.setup_php_ini_dir("extension=redis.so\nextension=igbinary.so")
     validate_php_ini_extensions(ctx)
     eq_([], ctx['PHP_EXTENSIONS'])
示例#6
0
 def test_validate_php_ini_extensions_when_redis_is_specified_without_igbinary(
         self, supported_func, compiled_func):
     ctx = {
         'BUILD_DIR': self.build_dir,
         'PHP_EXTENSIONS': [],
     }
     self.setup_php_ini_dir("extension=redis.so")
     validate_php_ini_extensions(ctx)
     eq_(['igbinary'], ctx['PHP_EXTENSIONS'])
示例#7
0
    def _compile(self, install):
        ctx = install.builder._ctx

        (composer_json_file, composer_lock_file) = find_composer_paths(ctx)
        options_json_file = os.path.join(ctx['BUILD_DIR'],'.bp-config', 'options.json')

        if (os.path.isfile(options_json_file) and composer_json_file and os.path.isfile(composer_json_file)):
            # options.json and composer.json both exist. Check to see if both define a PHP version.
            composer_json = json.load(open(composer_json_file,'r'))
            options_json = json.load(open(options_json_file,'r'))

            if composer_json.get('require', {}).get('php') and options_json.get("PHP_VERSION"):
                print('WARNING: A version of PHP has been specified in both `composer.json` and `./bp-config/options.json`.')
                print('WARNING: The version defined in `composer.json` will be used.')

        if ctx.get('OPTIONS_JSON_HAS_PHP_EXTENSIONS', False):
            print("Warning: PHP_EXTENSIONS in options.json is deprecated. See: http://docs.cloudfoundry.org/buildpacks/php/gsg-php-config.html")

        print 'Installing PHP'
        validate_php_version(ctx)
        print 'PHP %s' % (ctx['PHP_VERSION'])

        major_minor = '.'.join(string.split(ctx['PHP_VERSION'], '.')[0:2])

        (install
            .package('PHP')
            .done())

        validate_php_ini_extensions(ctx)
        validate_php_extensions(ctx)
        convert_php_extensions(ctx)
        include_fpm_d_confs(ctx)

        (install
            .config()
                .from_application('.bp-config/php')  # noqa
                .or_from_build_pack('defaults/config/php/%s.x' % major_minor)
                .to('php/etc')
                .rewrite()
                .done())

        return 0
示例#8
0
 def test_validate_php_ini_extensions_when_no_php_ini_dir(self, supported_func, compiled_func):
     ctx = {
         'BUILD_DIR': self.build_dir
     }
     validate_php_ini_extensions(ctx)
示例#9
0
 def test_validate_php_ini_extensions_when_extension_is_compiled_module(self, supported_func, compiled_func):
     ctx = {
         'BUILD_DIR': self.build_dir
     }
     self.setup_php_ini_dir("extension=pumpkin.so\nextension=apple.so\nextension = \"pie.so\"")
     validate_php_ini_extensions(ctx)
示例#10
0
 def test_validate_php_ini_extensions_when_no_php_ini_dir(
         self, supported_func, compiled_func):
     ctx = {'BUILD_DIR': self.build_dir}
     validate_php_ini_extensions(ctx)
示例#11
0
 def test_validate_php_ini_extensions_when_extension_is_compiled_module(
         self, supported_func, compiled_func):
     ctx = {'BUILD_DIR': self.build_dir}
     self.setup_php_ini_dir(
         "extension=pumpkin.so\nextension=apple.so\nextension = \"pie.so\"")
     validate_php_ini_extensions(ctx)