PHP code example of karelwintersky / arris.entity.path
1. Go to this page and download the library: Download karelwintersky/arris.entity.path library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
karelwintersky / arris.entity.path example snippets
use Arris\Entity\Path;
// Создать путь из строки
$path = new Path('/var/www/html');
echo $path; // /var/www/html
// Создать через фабричный метод
$path = Path::create('uploads/images');
echo $path->toString(); // uploads/images
// Соединить с подпутём
$full = Path::create('/var/www')->join('html/index.php');
echo $full; // /var/www/html/index.php
// URL-адрес тоже работает
$url = new Path('https://cdn.example.com/assets/app.js');
echo $url; // https://cdn.example.com/assets/app.js
if ((new Path('/var/log'))->isPresent()) { /* ... */ }
if ((new Path('/etc/hosts'))->isFile()) { /* ... */ }
$created = (new Path('/tmp/app/cache'))->makePath(0755);
$url = new Path('https://example.com/api/v1');
echo $url; // https://example.com/api/v1
// Двойной слэш в пути (не в схеме) схлопывается
$url = new Path('https://cdn.example.com/a//b');
echo $url; // https://cdn.example.com/a/b
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.