{"id":73188,"date":"2025-01-08T21:00:03","date_gmt":"2025-01-08T13:00:03","guid":{"rendered":"https:\/\/www.hongkiat.com\/blog\/?p=73188"},"modified":"2025-01-02T20:48:42","modified_gmt":"2025-01-02T12:48:42","slug":"how-to-install-php-extensions-with-pie","status":"publish","type":"post","link":"https:\/\/www.hongkiat.com\/blog\/how-to-install-php-extensions-with-pie\/","title":{"rendered":"How to Install PHP Extensions Easily with PIE"},"content":{"rendered":"<p>Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from source. These methods could be inconsistent across platforms and required different commands, making the process complex and prone to errors.<\/p>\n<p><a href=\"https:\/\/pecl.php.net\" target=\"_blank\" rel=\"noopener noreferrer\">PECL<\/a>, while helpful, feels antiquated. It\u2019s not as easy to put your extension in PHP as it is with Composer. <a href=\"https:\/\/github.com\/php\/pie\" target=\"_blank\" rel=\"noopener noreferrer\">PIE<\/a> is an initiative from <a href=\"https:\/\/thephp.foundation\" target=\"_blank\" rel=\"noopener noreferrer\">the PHP Foundation<\/a> to solve this by treating extensions as Composer packages. It simplifies the process, offers better cross-platform consistency, and ensures easier updates and management for PHP extensions.<\/p>\n<h2>Prerequisites<\/h2>\n<p>Before we begin, ensure you have PHP 8.1 or newer to run PIE. However, PIE can install extensions for any installed PHP version. To check the PHP version on your computer, you can run: <code>php -v<\/code><\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/how-to-install-php-extensions-with-pie\/php-v.jpg\" alt=\"Checking PHP version using php -v command\" width=\"750\" height=\"390\"><\/figure>\n<h2>Installation<\/h2>\n<p>To install the PHP Installer for Extensions (PIE), you can follow these steps:<\/p>\n<h3>1. Download the PHAR package<\/h3>\n<p>First, you need to download the <code>pie.phar<\/code> file from <a href=\"https:\/\/github.com\/php\/pie\" target=\"_blank\" rel=\"noopener noreferrer\">the official repository or website<\/a>. This is the primary file needed to use PIE.<\/p>\n<h3>2. PHAR installation<\/h3>\n<p>Move <code>pie.phar<\/code> into your computer\u2019s <code>PATH<\/code>, such as <code>\/usr\/local\/bin\/<\/code>, so you can run it from anywhere. You can rename it for convenience, for example:<\/p>\n<pre>\r\nmv pie.phar \/usr\/local\/bin\/pie\r\n<\/pre>\n<p>On Windows, you can move it to <code>C:\\Program Files<\/code> or any other directory in your <code>PATH<\/code>. However, I recommend using Composer and its CLI with the Windows Subsystem for Linux (WSL) for a better experience.<\/p>\n<h3>3. Make it executable<\/h3>\n<p>On non-Windows machines, you need to change the permissions to make it executable.<\/p>\n<pre>\r\nchmod +x \/usr\/local\/bin\/pie\r\n<\/pre>\n<p>That\u2019s it. You can try running <code>pie<\/code> in your terminal to see if it\u2019s installed correctly.<\/p>\n<figure><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/assets.hongkiat.com\/uploads\/how-to-install-php-extensions-with-pie\/php-pie-version.jpg\" alt=\"Checking PIE version after installation\" width=\"750\" height=\"480\"><\/figure>\n<p>We can now use PIE to install PHP extensions with ease using the <code>pie<\/code> command.<\/p>\n<pre>\r\npie install &lt;vendor&gt;\/&lt;package&gt;\r\n<\/pre>\n<p>For example, let\u2019s say you want to install the <code>xdebug<\/code> extension to perform debugging in your PHP application. You can run:<\/p>\n<pre>\r\npie install xdebug\/xdebug\r\n<\/pre>\n<p>This command will pull the <code>xdebug<\/code> extension from Packagist, build it, and install it in your PHP installation. PIE will also add the extension to your <code>php.ini<\/code> file, so you don\u2019t have to do it manually.<\/p>\n<p>You can find all extensions that you can install through PIE in <a href=\"https:\/\/packagist.org\/extensions\" target=\"_blank\" rel=\"noopener noreferrer\">Packagist<\/a>.<\/p>\n<h2>Note for Windows<\/h2>\n<p>PIE currently does not support building extensions on Windows. It relies on the extension author to provide the pre-built DLL file for their extension, so there are probably some extensions that you can\u2019t install on Windows.<\/p>\n<h2>Wrapping Up<\/h2>\n<p>PIE is a great initiative to simplify the installation of PHP extensions. I like how it treats extensions as Composer packages, making it easier to manage and update them. I think it\u2019s a step in the right direction to modernize the PHP ecosystem and make it more developer-friendly.<\/p>","protected":false},"excerpt":{"rendered":"<p>Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from source. These methods could be inconsistent across platforms and required different commands, making the process complex and prone to errors. PECL, while helpful, feels antiquated. It\u2019s not as easy to put your extension in PHP as it&hellip;<\/p>\n","protected":false},"author":113,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3392],"tags":[1319],"topic":[],"class_list":["entry-content","is-maxi"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v22.8 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Install PHP Extensions Easily with PIE - Hongkiat<\/title>\n<meta name=\"description\" content=\"Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.hongkiat.com\/blog\/?p=73188\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Install PHP Extensions Easily with PIE\" \/>\n<meta property=\"og:description\" content=\"Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.hongkiat.com\/blog\/?p=73188\" \/>\n<meta property=\"og:site_name\" content=\"Hongkiat\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hongkiatcom\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-08T13:00:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/assets.hongkiat.com\/uploads\/how-to-install-php-extensions-with-pie\/php-v.jpg\" \/>\n<meta name=\"author\" content=\"Thoriq Firdaus\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@tfirdaus\" \/>\n<meta name=\"twitter:site\" content=\"@hongkiat\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Thoriq Firdaus\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188\"},\"author\":{\"name\":\"Thoriq Firdaus\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\"},\"headline\":\"How to Install PHP Extensions Easily with PIE\",\"datePublished\":\"2025-01-08T13:00:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188\"},\"wordCount\":438,\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/how-to-install-php-extensions-with-pie\\\/php-v.jpg\",\"keywords\":[\"PHP\"],\"articleSection\":[\"Coding\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188\",\"name\":\"How to Install PHP Extensions Easily with PIE - Hongkiat\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/how-to-install-php-extensions-with-pie\\\/php-v.jpg\",\"datePublished\":\"2025-01-08T13:00:03+00:00\",\"description\":\"Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188#primaryimage\",\"url\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/how-to-install-php-extensions-with-pie\\\/php-v.jpg\",\"contentUrl\":\"https:\\\/\\\/assets.hongkiat.com\\\/uploads\\\/how-to-install-php-extensions-with-pie\\\/php-v.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?p=73188#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Install PHP Extensions Easily with PIE\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"name\":\"Hongkiat\",\"description\":\"Tech and Design Tips\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#organization\",\"name\":\"Hongkiat.com\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/wp-content\\\/uploads\\\/hkdc-logo-rect-yoast.jpg\",\"width\":1200,\"height\":799,\"caption\":\"Hongkiat.com\"},\"image\":{\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/hongkiatcom\",\"https:\\\/\\\/x.com\\\/hongkiat\",\"https:\\\/\\\/www.pinterest.com\\\/hongkiat\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/#\\\/schema\\\/person\\\/e7948c7a175d211496331e4b6ce55807\",\"name\":\"Thoriq Firdaus\",\"description\":\"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.\",\"sameAs\":[\"https:\\\/\\\/thoriq.com\",\"https:\\\/\\\/x.com\\\/tfirdaus\"],\"jobTitle\":\"Web Developer\",\"url\":\"https:\\\/\\\/www.hongkiat.com\\\/blog\\\/author\\\/thoriq\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Install PHP Extensions Easily with PIE - Hongkiat","description":"Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.hongkiat.com\/blog\/?p=73188","og_locale":"en_US","og_type":"article","og_title":"How to Install PHP Extensions Easily with PIE","og_description":"Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from","og_url":"https:\/\/www.hongkiat.com\/blog\/?p=73188","og_site_name":"Hongkiat","article_publisher":"https:\/\/www.facebook.com\/hongkiatcom","article_published_time":"2025-01-08T13:00:03+00:00","og_image":[{"url":"https:\/\/assets.hongkiat.com\/uploads\/how-to-install-php-extensions-with-pie\/php-v.jpg","type":"","width":"","height":""}],"author":"Thoriq Firdaus","twitter_card":"summary_large_image","twitter_creator":"@tfirdaus","twitter_site":"@hongkiat","twitter_misc":{"Written by":"Thoriq Firdaus"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188#article","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188"},"author":{"name":"Thoriq Firdaus","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807"},"headline":"How to Install PHP Extensions Easily with PIE","datePublished":"2025-01-08T13:00:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188"},"wordCount":438,"publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/how-to-install-php-extensions-with-pie\/php-v.jpg","keywords":["PHP"],"articleSection":["Coding"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188","url":"https:\/\/www.hongkiat.com\/blog\/?p=73188","name":"How to Install PHP Extensions Easily with PIE - Hongkiat","isPartOf":{"@id":"https:\/\/www.hongkiat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188#primaryimage"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188#primaryimage"},"thumbnailUrl":"https:\/\/assets.hongkiat.com\/uploads\/how-to-install-php-extensions-with-pie\/php-v.jpg","datePublished":"2025-01-08T13:00:03+00:00","description":"Installing PHP extensions traditionally involved challenges like finding precompiled binaries, using OS package managers, or manually compiling from","breadcrumb":{"@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.hongkiat.com\/blog\/?p=73188"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188#primaryimage","url":"https:\/\/assets.hongkiat.com\/uploads\/how-to-install-php-extensions-with-pie\/php-v.jpg","contentUrl":"https:\/\/assets.hongkiat.com\/uploads\/how-to-install-php-extensions-with-pie\/php-v.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.hongkiat.com\/blog\/?p=73188#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.hongkiat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Install PHP Extensions Easily with PIE"}]},{"@type":"WebSite","@id":"https:\/\/www.hongkiat.com\/blog\/#website","url":"https:\/\/www.hongkiat.com\/blog\/","name":"Hongkiat","description":"Tech and Design Tips","publisher":{"@id":"https:\/\/www.hongkiat.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.hongkiat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.hongkiat.com\/blog\/#organization","name":"Hongkiat.com","url":"https:\/\/www.hongkiat.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","contentUrl":"https:\/\/www.hongkiat.com\/blog\/wp-content\/uploads\/hkdc-logo-rect-yoast.jpg","width":1200,"height":799,"caption":"Hongkiat.com"},"image":{"@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/hongkiatcom","https:\/\/x.com\/hongkiat","https:\/\/www.pinterest.com\/hongkiat\/"]},{"@type":"Person","@id":"https:\/\/www.hongkiat.com\/blog\/#\/schema\/person\/e7948c7a175d211496331e4b6ce55807","name":"Thoriq Firdaus","description":"Thoriq is a writer for Hongkiat.com with a passion for web design and development. He is the author of Responsive Web Design by Examples, where he covered his best approaches in developing responsive websites quickly with a framework.","sameAs":["https:\/\/thoriq.com","https:\/\/x.com\/tfirdaus"],"jobTitle":"Web Developer","url":"https:\/\/www.hongkiat.com\/blog\/author\/thoriq\/"}]}},"jetpack_featured_media_url":"https:\/\/","jetpack_shortlink":"https:\/\/wp.me\/p4uxU-j2s","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/73188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/users\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/comments?post=73188"}],"version-history":[{"count":1,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/73188\/revisions"}],"predecessor-version":[{"id":73189,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/posts\/73188\/revisions\/73189"}],"wp:attachment":[{"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/media?parent=73188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/categories?post=73188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/tags?post=73188"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.hongkiat.com\/blog\/wp-json\/wp\/v2\/topic?post=73188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}