1. Go to this page and download the library: Download decodelabs/lucid 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/ */
decodelabs / lucid example snippets
use DecodeLabs\Lucid;
// This ensures the value is a string
$myString = Lucid::cast('string', 'This is a string');
// This is nullable
$notAString = Lucid::cast('?string', null);
// These are constraints - throws an exception
$myString = Lucid::cast('string', 'My very long piece of text', [
'maxLength' => 10,
'maxWords' => 4
]);
// Creates an instance of Carbon (DateTime)
$myDate = Lucid::cast('date','tomorrow', [
'min' => 'yesterday',
'max' => '+3 days'
]);
$result = Lucid::validate('int', 'potato', [
'min' => 4
]);
if(!$result->isValid()) {
// Do something with the potato
foreach($result->getErrors() as $error) {
echo $error->getMessage();
}
}
if(!Lucid::is('float', 'not a number')) {
// do something
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.