Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pointybeard/helpers-functions-files
A collection of helpful functions related to creating and modifying files and directories
https://github.com/pointybeard/helpers-functions-files
Last synced: 9 days ago
JSON representation
A collection of helpful functions related to creating and modifying files and directories
- Host: GitHub
- URL: https://github.com/pointybeard/helpers-functions-files
- Owner: pointybeard
- License: other
- Created: 2020-04-07T08:26:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-15T01:34:06.000Z (about 3 years ago)
- Last Synced: 2024-10-12T06:21:06.727Z (about 1 month ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# PHP Helpers: File Functions
- Version: v1.0.0
- Date: April 07 2020
- [Release notes](https://github.com/pointybeard/helpers-functions-files/blob/master/CHANGELOG.md)
- [GitHub repository](https://github.com/pointybeard/helpers-functions-files)A collection of helpful functions related to creating and modifying files and directories
## Installation
This library is installed via [Composer](http://getcomposer.org/). To install, use `composer require pointybeard/helpers-functions-files` or add `"pointybeard/helpers-functions-files": "~1.0"` to your `composer.json` file.
And run composer to update your dependencies:
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update### Requirements
This library makes use of the [pointybeard/helpers-exceptions-readabletrace](https://github.com/pointybeard/helpers-exceptions-readabletrace), [pointybeard/helpers-functions-flags](https://github.com/pointybeard/pointybeard/helpers-functions-flags), and [pointybeard/helpers-functions-cli](https://github.com/pointybeard/helpers-functions-cli) packages. They are installed automatically via composer.
To include all the [PHP Helpers](https://github.com/pointybeard/helpers) packages on your project, use `composer require pointybeard/helpers` or add `"pointybeard/helpers": "~1.2"` to your composer file.
## Usage
This library is a collection of helpful functions related to creating and modifying files and directories. They are included by the vendor autoloader automatically. The functions have a namespace of `pointybeard\Helpers\Functions\Files`
The following functions are provided:
- `realise_directory(string $path, int $flags = null): void`
- `create_symbolic_link(string $target, ?string $destination, int $flags = null): void`Example usage:
```php
getMessage());
}
// string(46) "ERROR: Symbolic link README.md already exists."/*** Example 3: Attempt to make a link to a file that doesn't exist ***/
try {
Files\create_symbolic_link('../NOTAFILE');
} catch (Files\Exceptions\Symlink\TargetMissingException $ex) {
var_dump('ERROR: '.$ex->getMessage());
}
// string(55) "ERROR: Symbolic link target ../NOTAFILE does not exist."/*** Example 4: Attempt to create a symbolic link where we don't have permissions to ***/
try {
// Go somewhere we're not supposed to
chdir('/');
Files\create_symbolic_link(realpath(__DIR__.'/LICENCE'), 'naughty');
} catch (Files\Exceptions\Symlink\CreationFailedException $ex) {
var_dump('ERROR: '.$ex->getMessage());
}
//string(160) "ERROR: Symbolic link '/naughty' could not be created. Returned:
// Failed to run command. Returned: ln: failed to create symbolic link 'naughty': Permission denied"```
## Support
If you believe you have found a bug, please report it using the [GitHub issue tracker](https://github.com/pointybeard/helpers-functions-files/issues), or better yet, fork the library and submit a pull request.
## Contributing
We encourage you to contribute to this project. Please check out the [Contributing documentation](https://github.com/pointybeard/helpers-functions-files/blob/master/CONTRIBUTING.md) for guidelines about how to get involved.
## License
"PHP Helpers: File Functions" is released under the [MIT License](http://www.opensource.org/licenses/MIT).