Provides a set of classes for PHP applications.
Note: This is an unstable repository in development and should be treated as an alpha.
- PHP 5.5 or greater
- CakePHP Utility Classes ^3.0.1 or grater - Only required the
Cake\Utility\Text
class (this is installed by Composer autotically).
Use this instructions to install NML into your vendor
directory as nelson6e65/php_nml
.
You will need Composer install and update NML and dependecies. For other alternative instructions, read alternative instructions.
- Move to your project root directory. Example:
cd /var/www/html/my-awesome-php-project
. - Run
composer require nelson6e65/php_nml
. This installsphp_nml
and dependencies in yourvendor
directory (yourcomposer.json
will be updated). - Configure your app to autoload classes by including the composer autoloader (
vendor/autoload.php
) in yourconfig.php
orbootstrap.php
(or whatever file that performs your autoloads). In most of modern PHP frameworks this is made automatically.
Read more about Composer installs here.
Note: Remember to add your vendor
dependencies to your .gitignore
file. (See why).
After install NML and configure your application, you will be able to use NML classes by importing/aliasing with the use operator:
<?php
//Example of Version usage:
use NelsonMartell\Version;
$nmlVersion = new Version(0, 6);
// Create Version object parsing from string
$nmlVersion = Version::parse('0.6.0');
// Explicit to string
echo $nmlVersion->toString();
// Implicit to string
echo $nmlVersion;
?>
<p>Nelson Martell Library, version <?= $nmlVersion ?></p>
For more details about available classes from NML, you can check the API Documentation.
You can, optionally, define the CODE_ANALYSIS
constant if you like some notices and warnings to be throws while you are coding/debugging. This is useful to watch some recommendations about usage of
some classes, functions, methods, etc.
<?php
# app/config.php
# . . .
define('CODE_ANALYSIS', true);
# . . .
?>