Skip to content

Commit 140d36d

Browse files
committed
update readme
1 parent d35bad1 commit 140d36d

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
# webforge-utils
22

33
[![Build Status](https://travis-ci.org/webforge-labs/webforge-utils.svg)](https://travis-ci.org/webforge-labs/webforge-utils)
4+
5+
6+
## whats included
7+
8+
- DateTime and Time classes for an advanced (and more concise) interface for the PHP::DateTime classes
9+
- A full functional File and Directory implementation that abstracts a lot of PHP file funtions
10+
- supports nearly every way to write a file path (and convert):
11+
- windows D:\www\something.php
12+
- unix /some/path
13+
- wrappers: vfs://some/file/topath
14+
- windows cygin /cydrive/d/www/someting.php
15+
- windows shares \\\\psc-laptop\shared\www\something.php
16+
- unix style windows paths (sublime and others): /D/www/something.php
17+
- copy dirs and files recursively
18+
- find files recursively
19+
- Commonly used Exceptions with better semantics and debug output (FileNotFound, NotImplemented, Deprecated)
20+
- Some simple Utils to debug and dump variables
21+
- A bunch of useful String and Array functions
22+
23+
## usage
24+
25+
- [Dir and File API](docs/dir-and-file.md)
26+
27+
## installation
28+
29+
Use [Composer](http://getcomposer.org) to install.
30+
```
31+
composer require webforge/utils
32+
```
33+
34+
## license
35+
36+
Copyright (c) 2015 ps-webforge.com
37+
38+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
39+
40+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
41+
42+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

docs/dir-and-file.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Dir and File
2+
3+
Dir and File help you to do very common, often typed actions with php file utils. Notice: every directory has a trailing slash or backslash at its end per default. You have to construct those paths with trailing slash as well, unless you use `Dir::factoryTS`
4+
5+
## usage
6+
```php
7+
$dir = new Dir('/my/root');
8+
9+
$dir->getFile('index.php')->writeContents('<?php echo "hello world"; ')->copy(new File('index.html', $dir));
10+
```
11+
12+
```php
13+
$dir->copy(Dir::createTemporary());
14+
```
15+
16+
```php
17+
$file->move(new File(...));
18+
$file->copy(new File(...));
19+
$file->copy(Dir::factoryTS(__DIR__));
20+
```
21+
22+
```php
23+
$file->getCreationTime();
24+
$file->getModificationTime()->format('d.m.Y H:i');
25+
$file->getAccessTime()->1i8n_format('d. F H:i');
26+
```
27+
28+
In most of the cases you will work with libraries and other devs that do not trailslash their directoriese
29+
30+
will return the path as string [w]ithout [t]railing [s]lash:
31+
```php
32+
$dir->wtsPath();
33+
```
34+
35+
will return the path as string with trailing slash:
36+
```php
37+
$dir->getPath();
38+
```
39+
40+
## umask and defaultMod
41+
42+
For historical reasons the default permissions for a new Directory created by Webforge are 0644 (octal). To make webforge respekt your umask, configure it and set the environment variable `WEBFORGE_UMASK_SET` to 1. It then will call mkdir() with 0777 (octal) so that your umask is respected.

0 commit comments

Comments
 (0)