Home Page
  • March 28, 2024, 01:29:38 pm *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Official site launch very soon, hurrah!



Post reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.
Name:
Email:
Subject:
Message icon:

Verification:

shortcuts: hit alt+s to submit/post or alt+p to preview


Topic Summary

Posted by: Dakusan
« on: October 03, 2015, 03:57:31 pm »

Original post for Missing phar wrapper can be found at https://www.castledragmire.com/Posts/Missing_phar_wrapper.
Originally posted on: 10/03/15

Phar files are PHP’s way of distributing an entire PHP solution in a single package file. I recently had a problem on my Cygwin PHP server that said “Unable to find the wrapper "phar" - did you forget to enable it when you configured PHP?”. I couldn’t find any solution for this online, so I played with it a bit.

The quick and dirty solution I came up with is to include the phar file like any normal PHP file, which sets your current working directory inside of the phar file. After that, you can include files inside the phar and then change your directory back to where you started. Here is the code I used:

if(preg_match('/^(?:win|cygwin)/i', PHP_OS))
{
   $CWD=getcwd();
   require_once('Scripts/PHPExcel.phar');
   require_once('PHPExcel/IOFactory.php');
   chdir($CWD);
}
else
   require_once('phar://Scripts/PHPExcel.phar/PHPExcel/IOFactory.php');