Skip to content

๐Ÿ˜ php library to call functions and catch triggered errors

License

Notifications You must be signed in to change notification settings

davidlienhard/functioncaller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

91 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

davidlienhard/functioncaller

๐Ÿ˜ php library to call functions and catch triggered errors

Latest Stable Version Source Code Software License Minimum PHP Version CI Status

Setup

You can install through composer with:

composer require davidlienhard/functioncaller:^1

Note: davidlienhard/functioncaller requires PHP 8.0

Example

<?php declare(strict_types=1);

use DavidLienhard\FunctionCaller\Call as FunctionCaller;

$caller = new FunctionCaller("file", "testfile.txt");   // create caller instance
$result = $caller->getResult();                         // get result from call

if ($result === false) {                                // check if function has return false
    $errstr = $caller->getLastError()?->getErrstr();    // get error string
    $errno = $caller->getLastError()?->getErrno();      // get error number

    throw new \Exception("unable to read file 'testfile.php': ".$errstr." (".$errno.")");
}

License

The MIT License (MIT). Please see LICENSE for more information.

About

๐Ÿ˜ php library to call functions and catch triggered errors

Resources

License

Stars

Watchers

Forks

Languages