Search by

soft-tech-mx / os-reccon

Paquete PHP para realizar tareas genericas relacionadas con directorios en diferentes sistemas operativos.

Maintainers

Package info

github.com/SoftTechMX/lib-php-os-reccon

pkg:composer/soft-tech-mx/os-reccon

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-09-03 23:38 UTC

This package is auto-updated.

Last update: 2026-09-03 23:43:02 UTC


README

Cross-platform OS detection and filesystem utilities for PHP. Works consistently across Windows, Linux, and macOS.

Installation

composer require soft-tech-mx/os-reccon

Why?

PHP handles a lot of OS-specific details inconsistently — home directory environment variables, path separators, directory permissions — and it's easy to write code that only works on the OS you happen to be developing on. OsReccon wraps these details behind a single, tested API so your code behaves the same on every platform.

Usage

use SoftTechMX\OsReccon;

// System info
OsReccon::getOsName();              // "Windows", "Linux", "macOS", "FreeBSD", etc.
OsReccon::getHomeDirectory();       // Current user's home directory
OsReccon::getDirectorySeparator();  // "/" or "\" depending on the OS

// Directory listing
OsReccon::getDirectories($path);    // array<string>|null — subdirectory names in $path
OsReccon::getFiles($path);          // array<string>|null — file names in $path

// File operations
OsReccon::getFileSize($path, 'MB'); // float|null — file size in B, KB, MB, or GB
OsReccon::createTextFile($path, $content, overwrite: true);
OsReccon::readTextFile($path);      // string|null
OsReccon::deleteFile($path);        // bool|null

// Directories
OsReccon::createDirectory($path, 0755); // bool|null

API Reference

Method Returns Description
getOsName() string Human-readable OS name (Windows, macOS, Linux, FreeBSD, etc.)
getHomeDirectory() string Current user's home directory, resolved correctly per OS
getDirectorySeparator() string / on Linux/macOS, \ on Windows
getDirectories(string $path) array|null Directory names inside $path, or null on error
getFiles(string $path) array|null File names inside $path, or null on error
getFileSize(string $path, string $unit = 'MB', int $decimals = 2) float|null File size in the requested unit
deleteFile(string $path) bool|null true on success, false on failure, null if the file doesn't exist
createDirectory(string $path, int $permissions = 0755) bool|null true if created, false if it already existed or failed, null on path conflict
createTextFile(string $path, string $content = '', bool $overwrite = true) bool|null true/false on write result, null if it exists and $overwrite is false
readTextFile(string $path) string|null File contents, or null if unreadable

Requirements

  • PHP 8.0+

License

MIT