|  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: 2021-06-22 14:16 UTC
From: janpoem at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: Filesystem function related
PHP Version: 7.0.3 OS: Windows 10
Private report: No CVE-ID: None
 [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


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-22 14:16 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-06-22 14:16 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jul 30 18:01:30 2021 UTC