1. Go to this page and download the library: Download seanmorris/ids library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
seanmorris / ids example snippets
use \SeanMorris\Ids\Settings;
$someVar = Settings::read('some', 'var');
$someOtherVar = Settings::read('some', 'otherVar');
use \SeanMorris\Ids\Log;
Log::trace(...$messages); # Log a message along with a stacktrace.
Log::query(...$messages); # Log query-level information
Log::debug(...$messages); # Log debug information
Log::info(...$messages); # Log general information
Log::warn(...$messages); # Issue a warning
Log::error(...$messages); # Issue an error
use \SeanMorris\Ids\Disk\File;
$file = File::open($filename);
//Check if file existsif($file->check())
{
// ...
}
//Get the path to the file
$path = $file->name();
//Copy the file to another location.
$copiedFile = $file->copy($newLocation);
// Read byte-by-bytewhile(!$file->eof())
{
$byte = $file->read(1);
}
// Read entire file:
$content = $file->slurp();
// Append
$file->write($content);
// Overwrite
$file->write($content, FALSE);
namespaceSeanMorris\ExamplePackage\Idilic\Route;
classRootRouteimplements \SeanMorris\Ids\Routable{
/** Help text goes here. */publicfunctioncommandName($router){}
}
namespaceAuthor\Package;
use \DatetimeCollection;
use \SeanMorris\Ids\Collection;
// Create DatetimeCollection based on the existing Collection class
Collection::of(Datetime::CLASS, DatetimeCollection::CLASS);
// Create an instance of the new class:
$datetimeCollection = new DatetimeCollection();
use \SeanMorris\Ids\Injectable;
(newclass{ useInjectable; })::inject([], AwesomeInjectable::CLASS);
classAwesomeClassextendsAwesomeInjectable{
publicfunctionsomeMethod(){
// here there be behaviors...
}
}
// Inherit injected classes normally:classCoolDateFormatterextendsDateFormatter{
// ...
}
// Or create new subclasses by injecting the class and passing a new name:// (AwesomeDateFormatter is being created based on DateFormatter here)
DateFormatter::inject([
InjectedDate::CLASS => \Awesome\Project\AwesomeDatetime::CLASS
], AwesomeDateFormatter::CLASS);
classEvenCoolerDateFormatterextendsAwesomeDateFormatter{
// ...
}
use \SeanMorris\Ids\Collection;
use \SeanMorris\Ids\WrappedMethod;
$RankIterator = $collectionClass::$RankIterator::inject([
'map' => WrappedMethod::wrap($callback)
]);
$mappedCollection = Collection::inject([
'RankIterator' => $RankIterator
]);
use \SeanMorris\Ids\Collection;
use \SeanMorris\Ids\WrappedMethod;
$collectionClass::$RankIterator::inject([
'map' => WrappedMethod::wrap($callback)
], \InjectedRankIterator::CLASS);
classSubInjectedRankIteratorextendsInjectedRankIterator{
//...
}
$mappedCollection = Collection::inject([
'RankIterator' => SubInjectedRankIterator::CLASS
]);
use \SeanMorris\Ids\Injectable;
classRegularOldClass{
// ...
}
(newclass() extendsRegularOldClass{ useInjectable; })::inject(
[], InjectableRegularOldClass::CLASS
);
$object = new InjectableRegularOldClass();
use \SeanMorris\Ids\Loader;
// We can alias classes even if they don't exist yet:// If we were in a namespace, this would prevent it// from inheriting the FQNS.use \___\LogFileInjectable;
Loader::define([ LogFileInjectable::CLASS => ActualLogFileClass::CLASS ]);
use \SeanMorris\Ids\Mail;
$mail = new \SeanMorris\Ids\Mail;
$mail->body(<<<EOM
Message body here.
EOM);
$mail->from(\SeanMorris\Ids\Settings::read('noreply'));
$mail->subject('Hello from Ids!');
$mail->to($recipientEmail);
$mail->send(TRUE);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.