Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build/log
build/docs
build/dist
tmp
package.xml
3 changes: 1 addition & 2 deletions .sami.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
;

$versions = GitVersionCollection::create($dir)
->addFromTags('v0.3.*')
->add('master', 'master branch')
->addFromTags('*')
;

return new Sami($iterator, array(
Expand Down
56 changes: 51 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,64 @@
.PHONY: cs md cov pear
.PHONY: cs md cov pear docs check

PHP_VFS_BUILD_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
PHP_VFS_BUILD_REV=$(shell git rev-parse HEAD)

cs:
phpcs --standard=PSR2 src/

md:
phpmd src/

test:
vendor/bin/phpunit

cov:
phpunit --coverage-html=build/log/coverage
vendor/bin/phpunit --coverage-html=build/log/coverage
open build/log/coverage/index.html

pear:
ifndef version
check:
$(error Usage: make tag version=...)
else
check:
@git diff --quiet HEAD || (echo WORKING DIRECTORY DIRTY && false)
endif

setup-pear:
git remote add pear [email protected]:thornag/pear.git || true
git fetch pear
git checkout pear || git checkout -b pear pear/gh-pages
git checkout -
sudo pear channel-discover pear.michaeldonat.net || true
mkdir -p build/dist

pear: check setup-pear
./build/pear/package.php --source=src/ --version=$(version) > package.xml
pear package
mv VirtualFileSystem-$(version).tgz build/dist/
/usr/local/opt/php55/bin/pirum add ../pear.thornag.github.io build/dist/VirtualFileSystem-$(version).tgz
cd ../pear.thornag.github.io && git add . && git commit -a -m'adding VirtualFileSystem-$(version).tgz' && git push
git checkout pear
/usr/local/opt/php55/bin/pirum add . build/dist/VirtualFileSystem-$(version).tgz
git add . && git commit -a -m'adding VirtualFileSystem-$(version).tgz' && git push pear pear:gh-pages
git checkout -f -

docs:
@git diff --quiet HEAD || (echo WORKING DIRECTORY DIRTY && false)
./vendor/bin/sami.php update .sami.php
vendor/bin/phpunit --coverage-html=build/log/coverage
git checkout gh-pages
git pull
mkdir -p api
cp -rf build/docs/api/* api/
git add api
mkdir -p coverage
cp -rf build/log/coverage/* coverage/
git add coverage
git commit -m"auto-generated coverage & API docs for $(PHP_VFS_BUILD_BRANCH):$(PHP_VFS_BUILD_REV)" || true
git push
git checkout $(PHP_VFS_BUILD_BRANCH)

tag: check
git tag v$(version)
git push --tags

deploy: tag pear docs
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ API

While using low level API for interaction with php-vfs is at its core, a much easier approach is to mock filesystem using provided interface.

There are generally 2 methods you should always use when mocking up the state:
There are generally 4 methods you should always use when mocking up the state:

- ```\VirtualFileSystem\FileSystem::createDirectory($path, $recursive, $mode)``` used to mock directory;
- ```\VirtualFileSystem\FileSystem::createFIle($path, $data)``` used to mock file and its contents.
- ```\VirtualFileSystem\FileSystem::createFile($path, $data)``` used to mock file and its contents.
- ```\VirtualFileSystem\FileSystem::createLink($linkPath, $targetPath)``` used to mock symlink.
- ```\VirtualFileSystem\FileSystem::createStructure(array $structure)``` used to mock filesystem from array.

Combining above 2 should allow you to recreate any directory/file structure.
Combining above should allow you to recreate any directory/file structure.

Full API documentation is available [here](http://thornag.github.io/php-vfs/api/master).

Expand All @@ -172,18 +174,6 @@ php-vfs tries to mimic unix filesystem as much as possible. The same conditions

Most of [PHP filesystem functions](http://www.php.net/manual/en/ref.filesystem.php) are happily supported by php-vfs as long as the full file URL is passed as argument (using ```$fs->path()```). If you find something not working and not listed below please rise an issue on [github issues page](https://github.com/thornag/php-vfs/issues).

**Supported**

- fopen modes
- setting permissions and ownership
- directory iteration
- file access/modification/change times
- file/directory permissions when opening for reading/writing

**Currently unsupported**

- permission/ownership checks for touch (roadmap for 1.0.1)

**Known pitfalls**

streamWrapper implementations like php-vfs will not work with glob methods for directory iteration - you need to use ```DirectoryIterator``` or ```readdir()``` instead.
Expand All @@ -194,3 +184,14 @@ Contributing
Any contributions are more than welcome. Please make sure that you keep to [PSR-2](http://www.php-fig.org/psr/psr-2/) standards and provide tested code.

You are more than welcome to add yourself to CONTRIBUTORS.md.

Changes in 1.1.0
----------------

For full diff of changes please go to https://github.com/thornag/php-vfs/compare/v1.0.0...1.1.x

- added support for symlinks
- fixed Windows compatibility issues
- provided method to recreate dir/file structure from array [createStructure method]
- added permission support where it was previously not available (touch etc)

4 changes: 2 additions & 2 deletions build/pear/package.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function run()
protected function getInstallListing($directory, $cut, $parentNode)
{
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS));
foreach($objects as $name => $object){
foreach ($objects as $name => $object) {
$file = ltrim(str_replace($cut, '', $name), '/');
$as = ltrim(str_replace($directory, '', $name), '/');
$parentNode->appendChild($node = new DOMElement('install'));
Expand Down Expand Up @@ -123,4 +123,4 @@ public function usage()
if (realpath($argv[0]) == realpath(__FILE__)) {
$pxml = new PackageXML();
$pxml->run();
}
}
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
"php": ">=5.4.0"
},
"require-dev": {
"satooshi/php-coveralls": "dev-master"
"satooshi/php-coveralls": "dev-master",
"phpunit/phpunit": "~4.0",
"sami/sami": "*"
},
"type": "library"
}
Loading