Skip to content

Commit

Permalink
[email protected]: new formula
Browse files Browse the repository at this point in the history
Closes #159.

Signed-off-by: Sean Molenaar <[email protected]>
  • Loading branch information
SMillerDev committed Jan 10, 2025
1 parent b9f2ad6 commit f304661
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions Formula/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class PhpHttpAT83 < Formula
desc "Pecl HTTP Extension for PHP"
homepage "https://github.com/m6w6/ext-http"
url "https://pecl.php.net/get/pecl_http-4.2.6.tgz"
sha256 "cd33230050b3f7c5ddb6f4383ce2a81f0bcdb934432029eec72ebf0f942b876d"
head "https://github.com/m6w6/ext-http.git", branch: "master"

depends_on "autoconf" => :build
depends_on "pkg-config" => :build
depends_on "brotli"
depends_on "curl"
depends_on "icu4c@76"
depends_on "openssl@3"
depends_on "[email protected]"
depends_on "[email protected]"

uses_from_macos "zlib"

def module_path
extension_dir = Utils.safe_popen_read("#{Formula["[email protected]"].opt_bin}/php-config", "--extension-dir").chomp
php_basename = File.basename(extension_dir)
"php/#{php_basename}"
end

def install
cd "pecl_http-#{version}"
system Formula["[email protected]"].bin/"phpize"

mkdir "ext"
# link in the raphf extension header
cp_r "#{Formula["[email protected]"].include}/raphf", "ext/raphf"

sdkpath = ""
sdkpath = MacOS.sdk_path_if_needed if OS.mac?

configure_args = %W[
--with-http
--without-http-libidn-dir
--without-http-libidn2-dir
--without-http-libidnkit-dir
--without-http-libidnkit2-dir
--with-libdir=#{HOMEBREW_PREFIX}/lib
--with-php-config=#{Formula["[email protected]"].opt_bin/"php-config"}
--with-http-zlib-dir=#{sdkpath}/usr
--with-http-libcurl-dir=#{Formula["curl"].opt_lib}
--with-http-libicu-dir=#{sdkpath}/usr
]
system "./configure", *configure_args
system "make"
(lib/module_path).install "modules/http.so"
end

def post_install
ext_config_path = etc/"php"/Formula["[email protected]"].version.major_minor/"conf.d"/"20-ext-http.ini"
if ext_config_path.exist?
inreplace ext_config_path,
/extension=.*$/, "extension=\"#{opt_lib/module_path}/http.so\""
else
ext_config_path.write <<~EOS
[pecl_http]
extension="#{opt_lib/module_path}/http.so"
EOS
end
end

test do
assert_match "http", shell_output("#{Formula["[email protected]"].opt_bin}/php -m").downcase,
"failed to find extension in php -m output"
end
end

0 comments on commit f304661

Please sign in to comment.