|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71616 realpath and DirectoryIterator::getRealPath not work in phar pack file
Submitted: 2016-02-17 09:27 UTC Modified: -
From: janpoem at gmail dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: 7.0.3 OS: Windows 10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: janpoem at gmail dot com
New email:
PHP Version: OS:


 [2016-02-17 09:27 UTC] janpoem at gmail dot com
This is a very strange question. It looks realpath returns false, but it's not. This happens in the phar file.

Test script:
 * realpath not work in phar pack file

$paths = [

function let_it_work(string $path)
	$realPath = realpath($path);
	if ($realPath !== false) {
		$path = $realPath;
	return $path;

function show_false(string $path)
	return realpath($path);

foreach ($paths as $path) {
	var_dump(file_exists($path)); // return true
	var_dump(realpath($path)); // return false
	var_dump(let_it_work($path)); // it's work
	var_dump(show_false($path)); // return false

function entry(DirectoryIterator $dir = null)
	if ($dir === null)
		$dir = new DirectoryIterator(__DIR__);
	foreach ($dir as $item) {
		$path = $item->getPathname();
		var_dump(file_exists($path)); // true
		var_dump($item->getRealPath()); // false

entry(new DirectoryIterator('phar://phar_test.phar'));


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri May 14 08:01:23 2021 UTC