|
| 1 | +class PhpAutoloadPsrAT83 < Formula |
| 2 | + desc "Autoload-PSR Extension for PHP" |
| 3 | + homepage "https://github.com/pprkut/autoload-psr" |
| 4 | + url "https://github.com/pprkut/autoload-psr/archive/refs/tags/0.2.1.tar.gz" |
| 5 | + sha256 "f089f837928f65aa73fbc39584ea0dfeb67fd39cb7e68c533386d188daf17604" |
| 6 | + head "https://github.com/pprkut/autoload-psr.git", branch: "master" |
| 7 | + |
| 8 | + bottle do |
| 9 | + root_url "https://github.com/SMillerDev/homebrew-tap/releases/download/php-autoload-psr-0.2.1" |
| 10 | + sha256 cellar: :any_skip_relocation, arm64_sequoia: "5d88beac3c904d4414c8d277edd3a37495cc36fdef13edd8effc210ca17a3dd5" |
| 11 | + sha256 cellar: :any_skip_relocation, ventura: "02dcbc1eaee4fdf5299d1e763cdbed2aaa1fb555a64558e13234cebb7add94ba" |
| 12 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "93911107ca444a541e429364c206f1e03033caeaef025510865ad5d249a08a0f" |
| 13 | + end |
| 14 | + |
| 15 | + depends_on "autoconf" => :build |
| 16 | + |
| 17 | + |
| 18 | + def module_path |
| 19 | + extension_dir = Utils.safe_popen_read("#{Formula["[email protected]"].opt_bin}/php-config", "--extension-dir").chomp |
| 20 | + php_basename = File.basename(extension_dir) |
| 21 | + "php/#{php_basename}" |
| 22 | + end |
| 23 | + |
| 24 | + def install |
| 25 | + system Formula["[email protected]"].bin/ "phpize" |
| 26 | + system "./configure", "--with-php-config=#{Formula["[email protected]"].opt_bin/"php-config"}" |
| 27 | + system "make" |
| 28 | + (lib/module_path).install "modules/autoload_psr.so" |
| 29 | + end |
| 30 | + |
| 31 | + def post_install |
| 32 | + ext_config_path = etc/ "php/#{Formula["[email protected]"].version.major_minor}/conf.d/ext-autoload_psr.ini" |
| 33 | + if ext_config_path.exist? |
| 34 | + inreplace ext_config_path, |
| 35 | + /extension=.*$/, "extension=\"#{opt_lib/module_path}/autoload_psr.so\"" |
| 36 | + else |
| 37 | + ext_config_path.write <<~EOS |
| 38 | + [autoload_psr] |
| 39 | + extension="#{opt_lib/module_path}/autoload_psr.so" |
| 40 | + EOS |
| 41 | + end |
| 42 | + end |
| 43 | + |
| 44 | + test do |
| 45 | + assert_match "autoload_psr", shell_output("#{Formula["[email protected]"].opt_bin}/php -m").downcase, |
| 46 | + "failed to find extension in php -m output" |
| 47 | + end |
| 48 | +end |
0 commit comments