{"id":4258,"date":"2021-04-23T15:25:31","date_gmt":"2021-04-23T06:25:31","guid":{"rendered":"\/blog\/?p=4258"},"modified":"2023-09-21T09:26:33","modified_gmt":"2023-09-21T00:26:33","slug":"php-%ec%86%8c%ec%8a%a4%ed%8c%8c%ec%9d%bc%eb%93%a4%ec%9d%84-phar%eb%a1%9c-%eb%ac%b6%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=4258","title":{"rendered":"[PHP] \uc18c\uc2a4\ud30c\uc77c\ub4e4\uc744 Phar\ub85c \ubb36\uae30"},"content":{"rendered":"\n<pre class=\"wp-block-syntaxhighlighter-code\">&lt;?php\n\/\/ php.ini\uc5d0\uc11c phar.readonly = Off \ub85c \uc124\uc815 \ud6c4 \uc0ac\uc6a9\ntry\n{\n    $pharFile = 'countrycurrency.phar';\n    \/\/ clean up\n    if (file_exists($pharFile))\n    {\n        unlink($pharFile);\n    }\n    if (file_exists($pharFile . '.gz'))\n    {\n        unlink($pharFile . '.gz');\n    }\n    \/\/ create phar\n    $phar = new Phar($pharFile);\n    \/\/ start buffering. Mandatory to modify stub to add shebang\n    $phar->startBuffering();\n    \/\/ Create the default stub from main.php entrypoint\n    $defaultStub = $phar->createDefaultStub('main.php');\n    \/\/ Add the rest of the apps files\n    $phar->buildFromDirectory(__DIR__ . '\/countryinfoservice');\n    \/\/ Customize the stub to add the shebang\n    $stub = \"#!\/usr\/bin\/env php \\n\" . $defaultStub;\n    \/\/ Add the stub\n    $phar->setStub($stub);\n    $phar->stopBuffering();\n    \/\/ plus - compressing it into gzip\n    $phar->compressFiles(Phar::GZ);\n    # Make the file executable\n    chmod(__DIR__ . '\/countrycurrency.phar', 0770);\n    echo \"$pharFile successfully created\" . PHP_EOL;\n}\ncatch (Exception $e)\n{\n    echo $e->getMessage();\n}\n?>\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&lt;?php \/\/ php.ini\uc5d0\uc11c phar.readonly = Off \ub85c \uc124\uc815 \ud6c4 \uc0ac\uc6a9 try { $pharFile = &#8216;countrycurrency.phar&#8217;; \/\/ clean up if (file_exists($pharFile)) { unlink($pharFile); } if (file_exists($pharFile . &#8216;.gz&#8217;)) { unlink($pharFile . &#8216;.gz&#8217;); } \/\/ create phar $phar = new Phar($pharFile); \/\/ start buffering. Mandatory to modify stub to add shebang $phar->startBuffering(); \/\/ Create the default stub [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[19],"tags":[],"class_list":["post-4258","post","type-post","status-publish","format-standard","hentry","category-development_lib"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4258"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4258\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4258"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4258"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}