quidphp / base
PHP library that provides a set of low-level static methods
Requires
- php: >=8.1.0
README
About
QuidPHP/Base is a PHP library that provides a set of low-level static methods. It is part of the QuidPHP package and can also be used standalone.
License
QuidPHP/Base is available as an open-source software under the MIT license.
Documentation
QuidPHP/Base documentation is available at QuidPHP/Docs.
Installation
QuidPHP/Base can be easily installed with Composer. It is available on Packagist.
$ composer require quidphp/base
Once installed, the Quid\Base namespace will be available within your PHP application.
Requirement
QuidPHP/Base requires the following:
- PHP 8.1 with these extensions:
- ctype
- curl
- date
- fileinfo
- gd
- iconv
- json
- mbstring
- pcre
- openssl
- session
- SimpleXML
- zip
Comment
QuidPHP/Base code is commented and all methods are explained (in French).
Convention
QuidPHP/Base is built on the following conventions:
- Coding: No curly braces are used in a IF statement if the condition can be resolved in only one statement.
- Config: A special $config static property exists in all classes. This property gets recursively merged with the parents' property on initialization.
- Error: The only exceptions that are thrown are related to function arguments and return types.
- Static: All class constructors are private, thus all methods are static and there is no object instantiation.
- Traits: Traits filenames start with an underscore (_).
- Type: Files, function arguments and return types are strict typed.
Overview
QuidPHP/Base contains 81 classes and traits. Here is an overview:
- Arr - Class with static methods to work with unidimensional arrays
- Arrs - Class with static methods to work with multidimensional arrays (an array containing at least another array)
- Assert - Class with methods a layer over the native PHP assert functions
- Assoc - Class to deal with associative strings and arrays
- Attr - Class with static methods to generate HTML attributes
- Autoload - Class with methods a layer over the native PHP autoload logic
- Boolean - Class with static methods to deal with boolean type
- Buffer - Class with methods a layer over the native PHP output buffering functions
- Call - Class with static methods to manage callables and callbacks
- Classe - Class with static methods to deal with classes using fully qualified class name strings
- Cli - Class with static methods to generate output for cli
- Column - Class with static methods to work with multidimensional column arrays (like a database query result array)
- Config - Class with config property, used for extending other classes
- Constant - Class with static methods to work with PHP constants
- Cookie - Class with static methods to add and remove cookies
- Crypt - Class which contains methods to deal with the most common PHP cryptography functions
- Csv - Class with static methods to easily work with CSV files
- Curl - Class with basic logics for managing requests via curl
- Datetime - Class with static methods to generate, format and parse dates
- Debug - Class with tools to help for debugging, also injects some helper functions
- Dir - Class with static methods to list, open and parse directories
- Email - Class with methods a layer over the native PHP send_mail function, handles mail headers
- Encoding - Class which contains methods related to string encoding (manages mb overload)
- Error - Class with methods a layer over the native PHP error functions and handler
- Exception - Class with methods a layer over the native PHP exception functions and handler
- Extension - Class which contains methods to deal with PHP extensions
- File - Class with static methods to create, read and write files (accepts path strings and resources)
- Finder - Class that provides methods to deal with the filesystem (used by Dir, File and Symlink)
- Finfo - Class with basic logics for managing the finfo extension
- Floating - Class with static methods to work with floating numbers
- Fqcn - Class with static methods to deal with fully qualified class name strings
- Func - Class with static methods to work with simple functions
- Globals - Class with static methods to manage global variables
- Header - Class with static methods to work with HTTP headers
- Html - Class with static methods for easily generating HTML
- Http - Class with static methods related to the HTTP protocol
- ImageRaster - Class with static methods to work with pixelated images
- Ini - Class with methods a layer over the native PHP ini functions
- Integer - Class with static methods to work with integers
- Ip - Class with static methods to work with IP strings
- Json - Class with static methods to encode and decode JSON
- Lang - Class to manage language text and translations
- Listing - Class to deal with associative strings and arrays
- Mime - Class with static methods to get or guess mime types
- Nav - Class which contains methods to build a complex pagination engine
- Network - Class with static network-related methods (dns, mx, ping, hostname and more)
- Num - Class with static methods to work with strings, ints and floats numbers
- Obj - Class with static methods to deal with objects, does not accept fqcn strings
- Path - Class with static methods to deal with filesystem paths
- PathTrack - Class with static methods to deal with filesystem paths (without a starting slash)
- Request - Class with static methods to analyze the current request
- Res - Class with static methods to create and modify resources of all types
- Response - Class with static methods to alter the current response
- Root - Abstract class extended by almost all others
- Scalar - Class with static methods to deal with scalar types
- Segment - Class that provides the logic to replace bracket segment within a string
- Server - Class that provides a set of methods to analyze the current server
- Session - Class with static methods to manage a session (built over the native PHP session functions)
- Set - Class with static methods to deal with set strings
- Slug - Class with static methods to deal with URI slugs
- SlugPath - Class with static methods to deal with URI slugs within an URI path
- Str - Class with static methods to work with strings
- Style - Class with static methods to generate an HTML style attribute
- Superglobal - Class with static methods to deal with superglobal variables
- Symlink - Class with static methods to manage symlinks
- Test - Abstract class used to create a testsuite for a class
- Timezone - Class with static methods to deal with timezone
- Uri - Class with static methods to generate URI (absolute and relative)
- UserAgent - Class with methods related to useragent
- Validate - Class that provides validation logic and methods
- Vari - Class with some general static methods related to variables
- Xml - Class with some static methods related to XML
- _cacheFile - Trait that provides methods to get or set a cached value from a file
- _cacheStatic - Trait that provides methods to get or set a cached value from a static property
- _config - Trait that grants static methods to get or set data within static config
- _init - Trait that provides the logic to recursively merge the static properties with the parent's properties
- _option - Trait that grants static methods to deal with static options (within the $config static property)
- _root - Trait that provides some basic fqcn methods
- _shortcut - Trait that grants static methods to declare and replace shortcuts (bracketed segments within strings)
Testing
QuidPHP/Base contains 70 test classes:
- Arr - Class for testing Quid\Base\Arr
- Arrs - Class for testing Quid\Base\Arrs
- Assert - Class for testing Quid\Base\Assert
- Assoc - Class for testing Quid\Base\Assoc
- Attr - Class for testing Quid\Base\Attr
- Autoload - Class for testing Quid\Base\Autoload
- Boolean - Class for testing Quid\Base\Boolean
- Buffer - Class for testing Quid\Base\Buffer
- Call - Class for testing Quid\Base\Call
- Classe - Class for testing Quid\Base\Classe
- Cli - Class for testing Quid\Base\Cli
- Column - Class for testing Quid\Base\Column
- Constant - Class for testing Quid\Base\Constant
- Cookie - Class for testing Quid\Base\Cookie
- Crypt - Class for testing Quid\Base\Crypt
- Csv - Class for testing Quid\Base\Csv
- Curl - Class for testing Quid\Base\Curl
- Datetime - Class for testing Quid\Base\Datetime
- Debug - Class for testing Quid\Base\Debug
- Dir - Class for testing Quid\Base\Dir
- Email - Class for testing Quid\Base\Email
- Encoding - Class for testing Quid\Base\Encoding
- Error - Class for testing Quid\Base\Error
- Exception - Class for testing Quid\Base\Exception
- Extension - Class for testing Quid\Base\Extension
- File - Class for testing Quid\Base\File
- Finder - Class for testing Quid\Base\Finder
- Finfo - Class for testing Quid\Base\Finfo
- Floating - Class for testing Quid\Base\Floating
- Fqcn - Class for testing Quid\Base\Fqcn
- Func - Class for testing Quid\Base\Func
- Globals - Class for testing Quid\Base\Globals
- Header - Class for testing Quid\Base\Header
- Html - Class for testing Quid\Base\Html
- Http - Class for testing Quid\Base\Http
- ImageRaster - Class for testing Quid\Base\ImageRaster
- Ini - Class for testing Quid\Base\Ini
- Integer - Class for testing Quid\Base\Integer
- Ip - Class for testing Quid\Base\Ip
- Json - Class for testing Quid\Base\Json
- Lang - Class for testing Quid\Base\Lang
- Listing - Class for testing Quid\Base\Listing
- Mime - Class for testing Quid\Base\Mime
- Nav - Class for testing Quid\Base\Nav
- Network - Class for testing Quid\Base\Network
- Num - Class for testing Quid\Base\Num
- Obj - Class for testing Quid\Base\Obj
- Path - Class for testing Quid\Base\Path
- PathTrack - Class for testing Quid\Base\PathTrack
- Request - Class for testing Quid\Base\Request
- Res - Class for testing Quid\Base\Res
- Response - Class for testing Quid\Base\Response
- Root - Class for testing Quid\Base\Root
- Scalar - Class for testing Quid\Base\Scalar
- Segment - Class for testing Quid\Base\Segment
- Server - Class for testing Quid\Base\Server
- Session - Class for testing Quid\Base\Session
- Set - Class for testing Quid\Base\Set
- Slug - Class for testing Quid\Base\Slug
- SlugPath - Class for testing Quid\Base\SlugPath
- Str - Class for testing Quid\Base\Str
- Style - Class for testing Quid\Base\Style
- Superglobal - Class for testing Quid\Base\Superglobal
- Symlink - Class for testing Quid\Base\Symlink
- Timezone - Class for testing Quid\Base\Timezone
- Uri - Class for testing Quid\Base\Uri
- UserAgent - Class for testing Quid\Base\UserAgent
- Validate - Class for testing Quid\Base\Validate
- Vari - Class for testing Quid\Base\Vari
- Xml - Class for testing Quid\Base\Xml
QuidPHP/Base testsuite can be run by creating a new QuidPHP/Assert project.