Exemple #1
0
 public function __construct($table = null)
 {
     //initiating R
     App::getInstance()->getContainer()->get('RedBean');
     if (!is_null($table)) {
         $this->_table = $table;
     } elseif (empty($this->_table)) {
         $class = get_called_class();
         $class = explode('\\', $class);
         $class = array_pop($class);
         $this->_table = strtolower(Inflect::pluralize($class));
     }
     $this->_bean = R::dispense($this->_table);
     if ($this->_timestamps) {
         $this->_bean->{'created_at'} = Carbon::now();
     }
 }
Exemple #2
0
/**
 * Hash a string
 *
 * @param string $string Plain text string.
 *
 * @return bool|string Returns the hash, or FALSE on failure.
 */
function zHash($string)
{
    return password_hash($string, \ZigiPhp\App::getConfig('hash')['algo'], \ZigiPhp\App::getConfig('hash')['options']);
}
Exemple #3
0
<?php

use ZigiPhp\App;
define('MF_START', microtime(true));
define('PUBLIC_PATH', dirname(__FILE__));
define('ROOT_PATH', dirname(PUBLIC_PATH));
define('APP_PATH', ROOT_PATH . '/app');
require_once ROOT_PATH . '/bootstrap/autoload.php';
/**
 * setting error reporting to maximum
 */
error_reporting(-1);
@ini_set('display_errors', 1);
/**
 * intiating app
 */
$app = new App();
$app->run();
	/** @noinspection PhpUnusedLocalVariableInspection */
	/** @noinspection PhpIllegalArrayKeyTypeInspection */
	/** @noinspection PhpUndefinedClassInspection */
	/** @noinspection PhpDeprecationInspection */
	$STATIC_METHOD_TYPES = [
		\ZigiPhp\Helpers\Collection::get('') => [
			%s
		],
	];
}
TAG;
error_reporting(-1);
@ini_set('display_errors', 1);
define('PUBLIC_PATH', dirname(__FILE__));
define('ROOT_PATH', dirname(__FILE__));
define('APP_PATH', ROOT_PATH . '/app');
require_once ROOT_PATH . '/bootstrap/autoload.php';
$app = new App();
$keys = array_keys($app->getContainer()->__toArray());
$result = [];
foreach ($keys as $key) {
    $value = $app->getContainer()->get($key);
    if (gettype($value) == 'object') {
        $result[] = sprintf("'{$key}' instanceof %s", get_class($value));
    } else {
        $result[] = sprintf("'{$key}' instanceof %s", gettype($value));
    }
}
$result = implode(',', $result);
file_put_contents(ROOT_PATH . '/.phpstorm.meta.php', sprintf($data, $result));
Exemple #5
0
 public function dispatch()
 {
     $match = App::getInstance()->getContainer()->get('Router')->match();
     self::route($match);
 }
<?php

/**
 * Blade service provider
 * @return \Philo\Blade\Blade
 */
use ZigiPhp\App;
return function () {
    $blade = new \Philo\Blade\Blade(App::getConfig('blade')['viewPath'], App::getConfig('blade')['cachePath']);
    $blade->getCompiler()->directive('trans', function ($expression) {
        return '<?php echo \\ZigiPhp\\Helpers\\I18n::__' . $expression . '; ?>';
    });
    $blade->getCompiler()->directive('form', function ($expression) {
        return '<?php ob_start(); ?>';
    });
    $blade->getCompiler()->directive('endform', function () {
        return '<?php \\ZigiPhp\\Helpers\\Form::create(ob_get_clean()); ?>';
    });
    return $blade;
};
<?php

/**
 * RedBean service provider
 * @return \RedBeanPHP\ToolBox
 */
use ZigiPhp\App;
return function () {
    return \RedBeanPHP\R::setup(App::getConfig('redbean')['dsn'], App::getConfig('redbean')['username'], App::getConfig('redbean')['password'], App::getConfig('redbean')['frozen']);
};
<?php

/**
 * @return PHPMailer
 */
return function () {
    $mailer = new \PHPMailer();
    if (isset(\ZigiPhp\App::getConfig('mail')['type'])) {
        switch (\ZigiPhp\App::getConfig('mail')['type']) {
            case 'sendmail':
                $mailer->isSendmail();
                break;
            case 'qmail':
                $mailer->isQmail();
                break;
            case 'smtp':
                $mailer->isSMTP();
                if (isset(\ZigiPhp\App::getConfig('mail')['options'])) {
                    foreach (\ZigiPhp\App::getConfig('mail')['options'] as $option => $value) {
                        $mailer->{$option} = $value;
                    }
                }
                break;
        }
    }
    return $mailer;
};