repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Validation.php
app/Config/Validation.php
<?php namespace Config; use CodeIgniter\Config\BaseConfig; use CodeIgniter\Validation\StrictRules\CreditCardRules; use CodeIgniter\Validation\StrictRules\FileRules; use CodeIgniter\Validation\StrictRules\FormatRules; use CodeIgniter\Validation\StrictRules\Rules; class Validation extends BaseConfig { // -------------------------------------------------------------------- // Setup // -------------------------------------------------------------------- /** * Stores the classes that contain the * rules that are available. * * @var list<string> */ public array $ruleSets = [ Rules::class, FormatRules::class, FileRules::class, CreditCardRules::class, ]; /** * Specifies the views that are used to display the * errors. * * @var array<string, string> */ public array $templates = [ 'list' => 'CodeIgniter\Validation\Views\list', 'single' => 'CodeIgniter\Validation\Views\single', ]; // -------------------------------------------------------------------- // Rules // -------------------------------------------------------------------- }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Cache.php
app/Config/Cache.php
<?php namespace Config; use CodeIgniter\Cache\CacheInterface; use CodeIgniter\Cache\Handlers\DummyHandler; use CodeIgniter\Cache\Handlers\FileHandler; use CodeIgniter\Cache\Handlers\MemcachedHandler; use CodeIgniter\Cache\Handlers\PredisHandler; use CodeIgniter\Cache\Handlers\RedisHandler; use CodeIgniter\Cache\Handlers\WincacheHandler; use CodeIgniter\Config\BaseConfig; class Cache extends BaseConfig { /** * -------------------------------------------------------------------------- * Primary Handler * -------------------------------------------------------------------------- * * The name of the preferred handler that should be used. If for some reason * it is not available, the $backupHandler will be used in its place. */ public string $handler = 'file'; /** * -------------------------------------------------------------------------- * Backup Handler * -------------------------------------------------------------------------- * * The name of the handler that will be used in case the first one is * unreachable. Often, 'file' is used here since the filesystem is * always available, though that's not always practical for the app. */ public string $backupHandler = 'dummy'; /** * -------------------------------------------------------------------------- * Key Prefix * -------------------------------------------------------------------------- * * This string is added to all cache item names to help avoid collisions * if you run multiple applications with the same cache engine. */ public string $prefix = ''; /** * -------------------------------------------------------------------------- * Default TTL * -------------------------------------------------------------------------- * * The default number of seconds to save items when none is specified. * * WARNING: This is not used by framework handlers where 60 seconds is * hard-coded, but may be useful to projects and modules. This will replace * the hard-coded value in a future release. */ public int $ttl = 60; /** * -------------------------------------------------------------------------- * Reserved Characters * -------------------------------------------------------------------------- * * A string of reserved characters that will not be allowed in keys or tags. * Strings that violate this restriction will cause handlers to throw. * Default: {}()/\@: * * NOTE: The default set is required for PSR-6 compliance. */ public string $reservedCharacters = '{}()/\@:'; /** * -------------------------------------------------------------------------- * File settings * -------------------------------------------------------------------------- * * Your file storage preferences can be specified below, if you are using * the File driver. * * @var array{storePath?: string, mode?: int} */ public array $file = [ 'storePath' => WRITEPATH . 'cache/', 'mode' => 0640, ]; /** * ------------------------------------------------------------------------- * Memcached settings * ------------------------------------------------------------------------- * * Your Memcached servers can be specified below, if you are using * the Memcached drivers. * * @see https://codeigniter.com/user_guide/libraries/caching.html#memcached * * @var array{host?: string, port?: int, weight?: int, raw?: bool} */ public array $memcached = [ 'host' => '127.0.0.1', 'port' => 11211, 'weight' => 1, 'raw' => false, ]; /** * ------------------------------------------------------------------------- * Redis settings * ------------------------------------------------------------------------- * * Your Redis server can be specified below, if you are using * the Redis or Predis drivers. * * @var array{host?: string, password?: string|null, port?: int, timeout?: int, database?: int} */ public array $redis = [ 'host' => '127.0.0.1', 'password' => null, 'port' => 6379, 'timeout' => 0, 'database' => 0, ]; /** * -------------------------------------------------------------------------- * Available Cache Handlers * -------------------------------------------------------------------------- * * This is an array of cache engine alias' and class names. Only engines * that are listed here are allowed to be used. * * @var array<string, class-string<CacheInterface>> */ public array $validHandlers = [ 'dummy' => DummyHandler::class, 'file' => FileHandler::class, 'memcached' => MemcachedHandler::class, 'predis' => PredisHandler::class, 'redis' => RedisHandler::class, 'wincache' => WincacheHandler::class, ]; /** * -------------------------------------------------------------------------- * Web Page Caching: Cache Include Query String * -------------------------------------------------------------------------- * * Whether to take the URL query string into consideration when generating * output cache files. Valid options are: * * false = Disabled * true = Enabled, take all query parameters into account. * Please be aware that this may result in numerous cache * files generated for the same page over and over again. * ['q'] = Enabled, but only take into account the specified list * of query parameters. * * @var bool|list<string> */ public $cacheQueryString = false; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Toolbar.php
app/Config/Toolbar.php
<?php namespace Config; use CodeIgniter\Config\BaseConfig; use CodeIgniter\Debug\Toolbar\Collectors\Database; use CodeIgniter\Debug\Toolbar\Collectors\Events; use CodeIgniter\Debug\Toolbar\Collectors\Files; use CodeIgniter\Debug\Toolbar\Collectors\Logs; use CodeIgniter\Debug\Toolbar\Collectors\Routes; use CodeIgniter\Debug\Toolbar\Collectors\Timers; use CodeIgniter\Debug\Toolbar\Collectors\Views; /** * -------------------------------------------------------------------------- * Debug Toolbar * -------------------------------------------------------------------------- * * The Debug Toolbar provides a way to see information about the performance * and state of your application during that page display. By default it will * NOT be displayed under production environments, and will only display if * `CI_DEBUG` is true, since if it's not, there's not much to display anyway. */ class Toolbar extends BaseConfig { /** * -------------------------------------------------------------------------- * Toolbar Collectors * -------------------------------------------------------------------------- * * List of toolbar collectors that will be called when Debug Toolbar * fires up and collects data from. * * @var list<class-string> */ public array $collectors = [ Timers::class, Database::class, Logs::class, Views::class, // \CodeIgniter\Debug\Toolbar\Collectors\Cache::class, Files::class, Routes::class, Events::class, ]; /** * -------------------------------------------------------------------------- * Collect Var Data * -------------------------------------------------------------------------- * * If set to false var data from the views will not be collected. Useful to * avoid high memory usage when there are lots of data passed to the view. */ public bool $collectVarData = true; /** * -------------------------------------------------------------------------- * Max History * -------------------------------------------------------------------------- * * `$maxHistory` sets a limit on the number of past requests that are stored, * helping to conserve file space used to store them. You can set it to * 0 (zero) to not have any history stored, or -1 for unlimited history. */ public int $maxHistory = 20; /** * -------------------------------------------------------------------------- * Toolbar Views Path * -------------------------------------------------------------------------- * * The full path to the the views that are used by the toolbar. * This MUST have a trailing slash. */ public string $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/'; /** * -------------------------------------------------------------------------- * Max Queries * -------------------------------------------------------------------------- * * If the Database Collector is enabled, it will log every query that the * the system generates so they can be displayed on the toolbar's timeline * and in the query log. This can lead to memory issues in some instances * with hundreds of queries. * * `$maxQueries` defines the maximum amount of queries that will be stored. */ public int $maxQueries = 100; /** * -------------------------------------------------------------------------- * Watched Directories * -------------------------------------------------------------------------- * * Contains an array of directories that will be watched for changes and * used to determine if the hot-reload feature should reload the page or not. * We restrict the values to keep performance as high as possible. * * NOTE: The ROOTPATH will be prepended to all values. * * @var list<string> */ public array $watchedDirectories = [ 'app', ]; /** * -------------------------------------------------------------------------- * Watched File Extensions * -------------------------------------------------------------------------- * * Contains an array of file extensions that will be watched for changes and * used to determine if the hot-reload feature should reload the page or not. * * @var list<string> */ public array $watchedExtensions = [ 'php', 'css', 'js', 'html', 'svg', 'json', 'env', ]; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Logger.php
app/Config/Logger.php
<?php namespace Config; use CodeIgniter\Config\BaseConfig; use CodeIgniter\Log\Handlers\FileHandler; use CodeIgniter\Log\Handlers\HandlerInterface; class Logger extends BaseConfig { /** * -------------------------------------------------------------------------- * Error Logging Threshold * -------------------------------------------------------------------------- * * You can enable error logging by setting a threshold over zero. The * threshold determines what gets logged. Any values below or equal to the * threshold will be logged. * * Threshold options are: * * - 0 = Disables logging, Error logging TURNED OFF * - 1 = Emergency Messages - System is unusable * - 2 = Alert Messages - Action Must Be Taken Immediately * - 3 = Critical Messages - Application component unavailable, unexpected exception. * - 4 = Runtime Errors - Don't need immediate action, but should be monitored. * - 5 = Warnings - Exceptional occurrences that are not errors. * - 6 = Notices - Normal but significant events. * - 7 = Info - Interesting events, like user logging in, etc. * - 8 = Debug - Detailed debug information. * - 9 = All Messages * * You can also pass an array with threshold levels to show individual error types * * array(1, 2, 3, 8) = Emergency, Alert, Critical, and Debug messages * * For a live site you'll usually enable Critical or higher (3) to be logged otherwise * your log files will fill up very fast. * * @var int|list<int> */ public $threshold = (ENVIRONMENT === 'production') ? 4 : 9; /** * -------------------------------------------------------------------------- * Date Format for Logs * -------------------------------------------------------------------------- * * Each item that is logged has an associated date. You can use PHP date * codes to set your own date formatting */ public string $dateFormat = 'Y-m-d H:i:s'; /** * -------------------------------------------------------------------------- * Log Handlers * -------------------------------------------------------------------------- * * The logging system supports multiple actions to be taken when something * is logged. This is done by allowing for multiple Handlers, special classes * designed to write the log to their chosen destinations, whether that is * a file on the getServer, a cloud-based service, or even taking actions such * as emailing the dev team. * * Each handler is defined by the class name used for that handler, and it * MUST implement the `CodeIgniter\Log\Handlers\HandlerInterface` interface. * * The value of each key is an array of configuration items that are sent * to the constructor of each handler. The only required configuration item * is the 'handles' element, which must be an array of integer log levels. * This is most easily handled by using the constants defined in the * `Psr\Log\LogLevel` class. * * Handlers are executed in the order defined in this array, starting with * the handler on top and continuing down. * * @var array<class-string<HandlerInterface>, array<string, int|list<string>|string>> */ public array $handlers = [ /* * -------------------------------------------------------------------- * File Handler * -------------------------------------------------------------------- */ FileHandler::class => [ // The log levels that this handler will handle. 'handles' => [ 'critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning', ], /* * The default filename extension for log files. * An extension of 'php' allows for protecting the log files via basic * scripting, when they are to be stored under a publicly accessible directory. * * NOTE: Leaving it blank will default to 'log'. */ 'fileExtension' => '', /* * The file system permissions to be applied on newly created log files. * * IMPORTANT: This MUST be an integer (no quotes) and you MUST use octal * integer notation (i.e. 0700, 0644, etc.) */ 'filePermissions' => 0644, /* * Logging Directory Path * * By default, logs are written to WRITEPATH . 'logs/' * Specify a different destination here, if desired. */ 'path' => '', ], /* * The ChromeLoggerHandler requires the use of the Chrome web browser * and the ChromeLogger extension. Uncomment this block to use it. */ // 'CodeIgniter\Log\Handlers\ChromeLoggerHandler' => [ // /* // * The log levels that this handler will handle. // */ // 'handles' => ['critical', 'alert', 'emergency', 'debug', // 'error', 'info', 'notice', 'warning'], // ], /* * The ErrorlogHandler writes the logs to PHP's native `error_log()` function. * Uncomment this block to use it. */ // 'CodeIgniter\Log\Handlers\ErrorlogHandler' => [ // /* The log levels this handler can handle. */ // 'handles' => ['critical', 'alert', 'emergency', 'debug', 'error', 'info', 'notice', 'warning'], // // /* // * The message type where the error should go. Can be 0 or 4, or use the // * class constants: `ErrorlogHandler::TYPE_OS` (0) or `ErrorlogHandler::TYPE_SAPI` (4) // */ // 'messageType' => 0, // ], ]; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Services.php
app/Config/Services.php
<?php namespace Config; use CodeIgniter\Config\BaseService; /** * Services Configuration file. * * Services are simply other classes/libraries that the system uses * to do its job. This is used by CodeIgniter to allow the core of the * framework to be swapped out easily without affecting the usage within * the rest of your application. * * This file holds any application-specific services, or service overrides * that you might need. An example has been included with the general * method format you should use for your service methods. For more examples, * see the core Services file at system/Config/Services.php. */ class Services extends BaseService { /* * public static function example($getShared = true) * { * if ($getShared) { * return static::getSharedInstance('example'); * } * * return new \CodeIgniter\Example(); * } */ }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Migrations.php
app/Config/Migrations.php
<?php namespace Config; use CodeIgniter\Config\BaseConfig; class Migrations extends BaseConfig { /** * -------------------------------------------------------------------------- * Enable/Disable Migrations * -------------------------------------------------------------------------- * * Migrations are enabled by default. * * You should enable migrations whenever you intend to do a schema migration * and disable it back when you're done. */ public bool $enabled = true; /** * -------------------------------------------------------------------------- * Migrations Table * -------------------------------------------------------------------------- * * This is the name of the table that will store the current migrations state. * When migrations runs it will store in a database table which migration * files have already been run. */ public string $table = 'migrations'; /** * -------------------------------------------------------------------------- * Timestamp Format * -------------------------------------------------------------------------- * * This is the format that will be used when creating new migrations * using the CLI command: * > php spark make:migration * * NOTE: if you set an unsupported format, migration runner will not find * your migration files. * * Supported formats: * - YmdHis_ * - Y-m-d-His_ * - Y_m_d_His_ */ public string $timestampFormat = 'Y-m-d-His_'; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Pager.php
app/Config/Pager.php
<?php namespace Config; use CodeIgniter\Config\BaseConfig; class Pager extends BaseConfig { /** * -------------------------------------------------------------------------- * Templates * -------------------------------------------------------------------------- * * Pagination links are rendered out using views to configure their * appearance. This array contains aliases and the view names to * use when rendering the links. * * Within each view, the Pager object will be available as $pager, * and the desired group as $pagerGroup; * * @var array<string, string> */ public array $templates = [ 'default_full' => 'CodeIgniter\Pager\Views\default_full', 'default_simple' => 'CodeIgniter\Pager\Views\default_simple', 'default_head' => 'CodeIgniter\Pager\Views\default_head', ]; /** * -------------------------------------------------------------------------- * Items Per Page * -------------------------------------------------------------------------- * * The default number of results shown in a single page. */ public int $perPage = 20; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Session.php
app/Config/Session.php
<?php namespace Config; use CodeIgniter\Config\BaseConfig; use CodeIgniter\Session\Handlers\BaseHandler; use CodeIgniter\Session\Handlers\FileHandler; class Session extends BaseConfig { /** * -------------------------------------------------------------------------- * Session Driver * -------------------------------------------------------------------------- * * The session storage driver to use: * - `CodeIgniter\Session\Handlers\FileHandler` * - `CodeIgniter\Session\Handlers\DatabaseHandler` * - `CodeIgniter\Session\Handlers\MemcachedHandler` * - `CodeIgniter\Session\Handlers\RedisHandler` * * @var class-string<BaseHandler> */ public string $driver = FileHandler::class; /** * -------------------------------------------------------------------------- * Session Cookie Name * -------------------------------------------------------------------------- * * The session cookie name, must contain only [0-9a-z_-] characters */ public string $cookieName = 'ci_session'; /** * -------------------------------------------------------------------------- * Session Expiration * -------------------------------------------------------------------------- * * The number of SECONDS you want the session to last. * Setting to 0 (zero) means expire when the browser is closed. */ public int $expiration = 7200; /** * -------------------------------------------------------------------------- * Session Save Path * -------------------------------------------------------------------------- * * The location to save sessions to and is driver dependent. * * For the 'files' driver, it's a path to a writable directory. * WARNING: Only absolute paths are supported! * * For the 'database' driver, it's a table name. * Please read up the manual for the format with other session drivers. * * IMPORTANT: You are REQUIRED to set a valid save path! */ public string $savePath = WRITEPATH . 'session'; /** * -------------------------------------------------------------------------- * Session Match IP * -------------------------------------------------------------------------- * * Whether to match the user's IP address when reading the session data. * * WARNING: If you're using the database driver, don't forget to update * your session table's PRIMARY KEY when changing this setting. */ public bool $matchIP = false; /** * -------------------------------------------------------------------------- * Session Time to Update * -------------------------------------------------------------------------- * * How many seconds between CI regenerating the session ID. */ public int $timeToUpdate = 300; /** * -------------------------------------------------------------------------- * Session Regenerate Destroy * -------------------------------------------------------------------------- * * Whether to destroy session data associated with the old session ID * when auto-regenerating the session ID. When set to FALSE, the data * will be later deleted by the garbage collector. */ public bool $regenerateDestroy = false; /** * -------------------------------------------------------------------------- * Session Database Group * -------------------------------------------------------------------------- * * DB Group for the database session. */ public ?string $DBGroup = null; /** * -------------------------------------------------------------------------- * Lock Retry Interval (microseconds) * -------------------------------------------------------------------------- * * This is used for RedisHandler. * * Time (microseconds) to wait if lock cannot be acquired. * The default is 100,000 microseconds (= 0.1 seconds). */ public int $lockRetryInterval = 100_000; /** * -------------------------------------------------------------------------- * Lock Max Retries * -------------------------------------------------------------------------- * * This is used for RedisHandler. * * Maximum number of lock acquisition attempts. * The default is 300 times. That is lock timeout is about 30 (0.1 * 300) * seconds. */ public int $lockMaxRetries = 300; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/View.php
app/Config/View.php
<?php namespace Config; use CodeIgniter\Config\View as BaseView; use CodeIgniter\View\ViewDecoratorInterface; /** * @phpstan-type parser_callable (callable(mixed): mixed) * @phpstan-type parser_callable_string (callable(mixed): mixed)&string */ class View extends BaseView { /** * When false, the view method will clear the data between each * call. This keeps your data safe and ensures there is no accidental * leaking between calls, so you would need to explicitly pass the data * to each view. You might prefer to have the data stick around between * calls so that it is available to all views. If that is the case, * set $saveData to true. * * @var bool */ public $saveData = true; /** * Parser Filters map a filter name with any PHP callable. When the * Parser prepares a variable for display, it will chain it * through the filters in the order defined, inserting any parameters. * To prevent potential abuse, all filters MUST be defined here * in order for them to be available for use within the Parser. * * Examples: * { title|esc(js) } * { created_on|date(Y-m-d)|esc(attr) } * * @var array<string, string> * @phpstan-var array<string, parser_callable_string> */ public $filters = []; /** * Parser Plugins provide a way to extend the functionality provided * by the core Parser by creating aliases that will be replaced with * any callable. Can be single or tag pair. * * @var array<string, callable|list<string>|string> * @phpstan-var array<string, list<parser_callable_string>|parser_callable_string|parser_callable> */ public $plugins = []; /** * View Decorators are class methods that will be run in sequence to * have a chance to alter the generated output just prior to caching * the results. * * All classes must implement CodeIgniter\View\ViewDecoratorInterface * * @var list<class-string<ViewDecoratorInterface>> */ public array $decorators = []; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Boot/development.php
app/Config/Boot/development.php
<?php /* |-------------------------------------------------------------------------- | ERROR DISPLAY |-------------------------------------------------------------------------- | In development, we want to show as many errors as possible to help | make sure they don't make it to production. And save us hours of | painful debugging. | | If you set 'display_errors' to '1', CI4's detailed error report will show. */ error_reporting(E_ALL); ini_set('display_errors', '1'); /* |-------------------------------------------------------------------------- | DEBUG BACKTRACES |-------------------------------------------------------------------------- | If true, this constant will tell the error screens to display debug | backtraces along with the other error information. If you would | prefer to not see this, set this value to false. */ defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true); /* |-------------------------------------------------------------------------- | DEBUG MODE |-------------------------------------------------------------------------- | Debug mode is an experimental flag that can allow changes throughout | the system. This will control whether Kint is loaded, and a few other | items. It can always be used within your own application too. */ defined('CI_DEBUG') || define('CI_DEBUG', true);
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Boot/production.php
app/Config/Boot/production.php
<?php /* |-------------------------------------------------------------------------- | ERROR DISPLAY |-------------------------------------------------------------------------- | Don't show ANY in production environments. Instead, let the system catch | it and display a generic error message. | | If you set 'display_errors' to '1', CI4's detailed error report will show. */ error_reporting(E_ALL & ~E_DEPRECATED); // If you want to suppress more types of errors. // error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); ini_set('display_errors', '0'); /* |-------------------------------------------------------------------------- | DEBUG MODE |-------------------------------------------------------------------------- | Debug mode is an experimental flag that can allow changes throughout | the system. It's not widely used currently, and may not survive | release of the framework. */ defined('CI_DEBUG') || define('CI_DEBUG', false);
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Config/Boot/testing.php
app/Config/Boot/testing.php
<?php /* * The environment testing is reserved for PHPUnit testing. It has special * conditions built into the framework at various places to assist with that. * You can’t use it for your development. */ /* |-------------------------------------------------------------------------- | ERROR DISPLAY |-------------------------------------------------------------------------- | In development, we want to show as many errors as possible to help | make sure they don't make it to production. And save us hours of | painful debugging. */ error_reporting(E_ALL); ini_set('display_errors', '1'); /* |-------------------------------------------------------------------------- | DEBUG BACKTRACES |-------------------------------------------------------------------------- | If true, this constant will tell the error screens to display debug | backtraces along with the other error information. If you would | prefer to not see this, set this value to false. */ defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true); /* |-------------------------------------------------------------------------- | DEBUG MODE |-------------------------------------------------------------------------- | Debug mode is an experimental flag that can allow changes throughout | the system. It's not widely used currently, and may not survive | release of the framework. */ defined('CI_DEBUG') || define('CI_DEBUG', true);
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Models/LanguagesModel.php
app/Models/LanguagesModel.php
<?php /** * Copyright (C) 2014, 2024 Richard Lobb * A pseudo model to manage the set of languages implemented * by Jobe. It's a pseudomodel that doesn't extend the base * Model class as it's not asociated with a database table. * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace App\Models; define('LANGUAGE_CACHE_FILE', '/tmp/jobe_language_cache_file'); class LanguagesModel { private static $languages = null; public static function findAll() { log_message('debug', 'findAll called'); $languages = self::supportedLanguages(); $langs = array(); foreach ($languages as $lang => $version) { $langs[] = array($lang, $version); } return $langs; } // Return an associative array mapping language name to language version // string for all supported languages (and only supported languages). public static function supportedLanguages() { if (self::$languages !== null) { return self::$languages; } $langCacheFile = LANGUAGE_CACHE_FILE; if (file_exists($langCacheFile)) { $langsJson = @file_get_contents($langCacheFile); $langs = json_decode($langsJson, true); // Security check, since this file is stored in /tmp where anyone could write it. foreach ($langs as $lang => $version) { if (!preg_match('/[a-zA-Z0-9]+/', $lang)) { $langs = null; // Looks like the file has been tampered with, re-compute. break; } if (!is_readable(self::getPathForLanguageTask($lang))) { $langs = null; // Looks like the file has been tampered with, re-compute. break; } } } if (empty($langs) || (is_array($langs) && isset($langs[0]))) { log_message('debug', 'Missing or corrupt languages cache file ... rebuilding it.'); $langs = []; $library_files = scandir(APPPATH . '/Libraries'); foreach ($library_files as $file) { $end = 'Task.php'; $pos = strpos($file, $end); if ($pos === strlen($file) - strlen($end)) { $lang = substr($file, 0, $pos); $class = "\\Jobe\\" . $lang . 'Task'; $version = $class::getVersion(); if ($version) { $langs[strtolower($lang)] = $version; } } } $langsJson = json_encode($langs); file_put_contents($langCacheFile, $langsJson); } self::$languages = $langs; return $langs; } /** * Get the path to the file that defines the language task for a given language. * * @param $lang the language of interest, e.g. cpp. * @return string the corresponding code path. */ public static function getPathForLanguageTask($lang) { return APPPATH . '/Libraries/' . ucfirst($lang) . 'Task.php'; } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Language/en/Validation.php
app/Language/en/Validation.php
<?php // override core en language system validation or define your own en language validation message return [];
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Filters/Cors.php
app/Filters/Cors.php
<?php namespace App\Filters; use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Config\Services; class Cors implements FilterInterface { /** * Called before processing of all requests to allow Cross Origin access. * * @param array|null $arguments * * @return mixed */ public function before(RequestInterface $request, $arguments = null) { // If it's a preflight request, return all the required headers for CORS access. if ($request->getMethod(true) === 'OPTIONS' && $request->hasHeader('Access-Control-Request-Method')) { $response = Services::response()->setStatusCode(204); return addCorsHeaders($response); } } /** * Called after processing of all requests to add all CORS filter if not present. * * @param array|null $arguments * * @return mixed */ public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { return addCorsHeaders($response); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/app/Filters/Throttle.php
app/Filters/Throttle.php
<?php /** * If API keys are enabled, and the key used in a RUN submission has a rate-limit, * this class enforces the rate limit on a per-IP basis to the per-hour limit set in the * Config file jobe.php. */ namespace App\Filters; use CodeIgniter\Filters\FilterInterface; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Config\Services; class Throttle implements FilterInterface { /** * Called before processing of POST ("run") requests to throttle rate if necessary. * * @param array|null $arguments * * @return mixed */ public function before(RequestInterface $request, $arguments = null) { $api_keys_in_use = config('Jobe')->require_api_keys; if ($api_keys_in_use) { $keys = config('Jobe')->api_keys; if (!$request->hasHeader('X-API-KEY')) { $response = Services::response()->setStatusCode(403)->setBody("Missing API key"); return addCorsHeaders($response); } $api_key_hdr = $request->header('X-API-KEY'); $api_key = explode(': ', $api_key_hdr)[1]; if (!array_key_exists($api_key, $keys)) { $response = Services::response()->setStatusCode(403)->setBody("Unknown API key"); return addCorsHeaders($response); } $rate_limit = $keys[$api_key]; if ($rate_limit) { $throttler = Services::throttler(); // Restrict an IP address to no more than the configured hourly rate limit for RUN requests only. $ip = $request->getIPAddress(); if ($throttler->check(md5($ip), $rate_limit, HOUR) === false) { log_message('debug', "Throttled IP $ip"); $response = Services::response()->setStatusCode(429)->setBody("Max RUN rate for this server exceeded"); return addCorsHeaders($response); } } } } /** * We don't have anything to do here. * * @param array|null $arguments * * @return mixed */ public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) { // ... } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/tests/session/ExampleSessionTest.php
tests/session/ExampleSessionTest.php
<?php use CodeIgniter\Test\CIUnitTestCase; /** * @internal */ final class ExampleSessionTest extends CIUnitTestCase { public function testSessionSimple(): void { $session = service('session'); $session->set('logged_in', 123); $this->assertSame(123, $session->get('logged_in')); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/tests/unit/HealthTest.php
tests/unit/HealthTest.php
<?php use CodeIgniter\Test\CIUnitTestCase; use Config\App; use Tests\Support\Libraries\ConfigReader; /** * @internal */ final class HealthTest extends CIUnitTestCase { public function testIsDefinedAppPath(): void { $this->assertTrue(defined('APPPATH')); } public function testBaseUrlHasBeenSet(): void { $validation = service('validation'); $env = false; // Check the baseURL in .env if (is_file(HOMEPATH . '.env')) { $env = preg_grep('/^app\.baseURL = ./', file(HOMEPATH . '.env')) !== false; } if ($env) { // BaseURL in .env is a valid URL? // phpunit.xml.dist sets app.baseURL in $_SERVER // So if you set app.baseURL in .env, it takes precedence $config = new App(); $this->assertTrue( $validation->check($config->baseURL, 'valid_url'), 'baseURL "' . $config->baseURL . '" in .env is not valid URL', ); } // Get the baseURL in app/Config/App.php // You can't use Config\App, because phpunit.xml.dist sets app.baseURL $reader = new ConfigReader(); // BaseURL in app/Config/App.php is a valid URL? $this->assertTrue( $validation->check($reader->baseURL, 'valid_url'), 'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL', ); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/tests/_support/Libraries/ConfigReader.php
tests/_support/Libraries/ConfigReader.php
<?php namespace Tests\Support\Libraries; use Config\App; /** * Class ConfigReader * * An extension of BaseConfig that prevents the constructor from * loading external values. Used to read actual local values from * a config file. */ class ConfigReader extends App { public function __construct() { } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/tests/_support/Database/Seeds/ExampleSeeder.php
tests/_support/Database/Seeds/ExampleSeeder.php
<?php namespace Tests\Support\Database\Seeds; use CodeIgniter\Database\Seeder; class ExampleSeeder extends Seeder { public function run(): void { $factories = [ [ 'name' => 'Test Factory', 'uid' => 'test001', 'class' => 'Factories\Tests\NewFactory', 'icon' => 'fas fa-puzzle-piece', 'summary' => 'Longer sample text for testing', ], [ 'name' => 'Widget Factory', 'uid' => 'widget', 'class' => 'Factories\Tests\WidgetPlant', 'icon' => 'fas fa-puzzle-piece', 'summary' => 'Create widgets in your factory', ], [ 'name' => 'Evil Factory', 'uid' => 'evil-maker', 'class' => 'Factories\Evil\MyFactory', 'icon' => 'fas fa-book-dead', 'summary' => 'Abandon all hope, ye who enter here', ], ]; $builder = $this->db->table('factories'); foreach ($factories as $factory) { $builder->insert($factory); } } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php
tests/_support/Database/Migrations/2020-02-22-222222_example_migration.php
<?php namespace Tests\Support\Database\Migrations; use CodeIgniter\Database\Migration; class ExampleMigration extends Migration { protected $DBGroup = 'tests'; public function up(): void { $this->forge->addField('id'); $this->forge->addField([ 'name' => ['type' => 'varchar', 'constraint' => 31], 'uid' => ['type' => 'varchar', 'constraint' => 31], 'class' => ['type' => 'varchar', 'constraint' => 63], 'icon' => ['type' => 'varchar', 'constraint' => 31], 'summary' => ['type' => 'varchar', 'constraint' => 255], 'created_at' => ['type' => 'datetime', 'null' => true], 'updated_at' => ['type' => 'datetime', 'null' => true], 'deleted_at' => ['type' => 'datetime', 'null' => true], ]); $this->forge->addKey('name'); $this->forge->addKey('uid'); $this->forge->addKey(['deleted_at', 'id']); $this->forge->addKey('created_at'); $this->forge->createTable('factories'); } public function down(): void { $this->forge->dropTable('factories'); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/tests/_support/Models/ExampleModel.php
tests/_support/Models/ExampleModel.php
<?php namespace Tests\Support\Models; use CodeIgniter\Model; class ExampleModel extends Model { protected $table = 'factories'; protected $primaryKey = 'id'; protected $returnType = 'object'; protected $useSoftDeletes = false; protected $allowedFields = [ 'name', 'uid', 'class', 'icon', 'summary', ]; protected $useTimestamps = true; protected $validationRules = []; protected $validationMessages = []; protected $skipValidation = false; }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/tests/database/ExampleDatabaseTest.php
tests/database/ExampleDatabaseTest.php
<?php use CodeIgniter\Test\CIUnitTestCase; use CodeIgniter\Test\DatabaseTestTrait; use Tests\Support\Database\Seeds\ExampleSeeder; use Tests\Support\Models\ExampleModel; /** * @internal */ final class ExampleDatabaseTest extends CIUnitTestCase { use DatabaseTestTrait; protected $seed = ExampleSeeder::class; public function testModelFindAll(): void { $model = new ExampleModel(); // Get every row created by ExampleSeeder $objects = $model->findAll(); // Make sure the count is as expected $this->assertCount(3, $objects); } public function testSoftDeleteLeavesRow(): void { $model = new ExampleModel(); $this->setPrivateProperty($model, 'useSoftDeletes', true); $this->setPrivateProperty($model, 'tempUseSoftDeletes', true); /** @var stdClass $object */ $object = $model->first(); $model->delete($object->id); // The model should no longer find it $this->assertNull($model->find($object->id)); // ... but it should still be in the database $result = $model->builder()->where('id', $object->id)->get()->getResult(); $this->assertCount(1, $result); } }
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
trampgeek/jobe
https://github.com/trampgeek/jobe/blob/cffff99685a78a2e13b47a5288e6fa87a1abe40a/public/index.php
public/index.php
<?php use CodeIgniter\Boot; use Config\Paths; /* *--------------------------------------------------------------- * CHECK PHP VERSION *--------------------------------------------------------------- */ $minPhpVersion = '8.1'; // If you update this, don't forget to update `spark`. if (version_compare(PHP_VERSION, $minPhpVersion, '<')) { $message = sprintf( 'Your PHP version must be %s or higher to run CodeIgniter. Current version: %s', $minPhpVersion, PHP_VERSION, ); header('HTTP/1.1 503 Service Unavailable.', true, 503); echo $message; exit(1); } /* *--------------------------------------------------------------- * SET THE CURRENT DIRECTORY *--------------------------------------------------------------- */ // Path to the front controller (this file) define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR); // Ensure the current directory is pointing to the front controller's directory if (getcwd() . DIRECTORY_SEPARATOR !== FCPATH) { chdir(FCPATH); } /* *--------------------------------------------------------------- * BOOTSTRAP THE APPLICATION *--------------------------------------------------------------- * This process sets up the path constants, loads and registers * our autoloader, along with Composer's, loads our constants * and fires up an environment-specific bootstrapping. */ // LOAD OUR PATHS CONFIG FILE // This is the line that might need to be changed, depending on your folder structure. require FCPATH . '../app/Config/Paths.php'; // ^^^ Change this line if you move your application folder $paths = new Paths(); // LOAD THE FRAMEWORK BOOTSTRAP FILE require $paths->systemDirectory . '/Boot.php'; exit(Boot::bootWeb($paths));
php
MIT
cffff99685a78a2e13b47a5288e6fa87a1abe40a
2026-01-05T05:19:26.518100Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Factory.php
src/Factory.php
<?php namespace EasyAlipay; /** * Class Factory. * * @method static \EasyAlipay\Payment\Application payment(array $config) * @method static \EasyAlipay\Mini\Application mini(array $config) * @method static \EasyAlipay\OpenPublic\Application openPublic(array $config) * @method static \EasyAlipay\Marketing\Application marketing(array $config) * @method static \EasyAlipay\BasicService\Application basicService(array $config) */ class Factory { /** * @param string $name * @param array $config * * @return \EasyAlipay\Kernel\ServiceContainer */ public static function make($name, array $config) { $namespace = Kernel\Support\Str::studly($name); $application = "\\EasyAlipay\\{$namespace}\\Application"; return new $application($config); } /** * Dynamically pass methods to the application. * * @param string $name * @param array $arguments * * @return mixed */ public static function __callStatic($name, $arguments) { return self::make($name, ...$arguments); } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Application.php
src/OpenPublic/Application.php
<?php namespace EasyAlipay\OpenPublic; use EasyAlipay\Kernel\ServiceContainer; /** * Class Application. * * @property \EasyAlipay\OpenPublic\Message\Client $message * @property \EasyAlipay\OpenPublic\Template\Client $template * */ class Application extends ServiceContainer { /** * @var array */ protected $providers = [ Message\ServiceProvider::class, Template\ServiceProvider::class, ]; }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Model/AlipayOpenPublicLifeMsgRecallContentBuilder.php
src/OpenPublic/Model/AlipayOpenPublicLifeMsgRecallContentBuilder.php
<?php namespace EasyAlipay\OpenPublic\Model; /* * * 功能:alipay.open.public.life.msg.recall(生活号消息撤回接口)业务参数封装 */ class AlipayOpenPublicLifeMsgRecallContentBuilder { // 消息id private $messageId; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getMessageId() { return $this->messageId; } public function setMessageId($messageId) { $this->messageId = $messageId; $this->bizContentarr['message_id'] = $messageId; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Model/AlipayOpenPublicTemplateMessageGetContentBuilder.php
src/OpenPublic/Model/AlipayOpenPublicTemplateMessageGetContentBuilder.php
<?php namespace EasyAlipay\OpenPublic\Model; /* * * 功能:alipay.open.public.template.message.get(消息模板领取接口)业务参数封装 */ class AlipayOpenPublicTemplateMessageGetContentBuilder { // 消息母板id,登陆生活号后台(fuwu.alipay.com),点击菜单“模板消息”,点击“模板库”,即可看到相应模板的消息母板id private $templateId; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTemplateId() { return $this->templateId; } public function setTemplateId($templateId) { $this->templateId = $templateId; $this->bizContentarr['template_id'] = $templateId; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Model/AlipayOpenPublicMessageSingleSendContentBuilder.php
src/OpenPublic/Model/AlipayOpenPublicMessageSingleSendContentBuilder.php
<?php namespace EasyAlipay\OpenPublic\Model; /* * * 功能:alipay.open.public.message.single.send(单发模板消息)业务参数封装 */ class AlipayOpenPublicMessageSingleSendContentBuilder { // 消息接收用户的userid private $toUserId; // 消息模板相关参数,其中包括templateId模板ID和context模板上下文 private $template; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getToUserId() { return $this->toUserId; } public function setToUserId($toUserId) { $this->toUserId = $toUserId; $this->bizContentarr['to_user_id'] = $toUserId; } public function getTemplate() { return $this->template; } public function setTemplate($template) { $this->template = $template; $this->bizContentarr['template'] = $template; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Model/AlipayOpenPublicMessageContentCreateContentBuilder.php
src/OpenPublic/Model/AlipayOpenPublicMessageContentCreateContentBuilder.php
<?php namespace EasyAlipay\OpenPublic\Model; /* * * 功能:alipay.open.public.message.content.create (创建图文消息内容接口)业务参数封装 */ class AlipayOpenPublicMessageContentCreateContentBuilder { // 标题 private $title; // 封面图url, 尺寸为996*450,最大不超过3M,支持格式:.jpg、.png ,请先调用图片上传接口(https://docs.open.alipay.com/api_3/alipay.offline.material.image.upload)获得图片url private $cover; // 消息正文(支持富文本) private $content; // 是否允许评论 T:允许 F:不允许,默认不允许 private $couldComment; // 图文类型 activity: 活动图文,不填默认普通图文 private $ctype; // 活动利益点,图文类型ctype为activity类型时才需要传,最多10个字符 private $benefit; // 关键词列表,英文逗号分隔,最多不超过5个 private $extTags; // 可预览支付宝账号列表,需要预览时才填写, 英文逗号分隔,最多不超过10个 private $loginIds; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTitle() { return $this->title; } public function setTitle($title) { $this->title = $title; $this->bizContentarr['title'] = $title; } public function getCover() { return $this->cover; } public function setCover($cover) { $this->cover = $cover; $this->bizContentarr['cover'] = $cover; } public function getContent() { return $this->content; } public function setContent($content) { $this->content = $content; $this->bizContentarr['content'] = $content; } public function getCouldComment() { return $this->couldComment; } public function setCouldComment($couldComment) { $this->couldComment = $couldComment; $this->bizContentarr['could_comment'] = $couldComment; } public function getCtype() { return $this->ctype; } public function setCtype($ctype) { $this->ctype = $ctype; $this->bizContentarr['ctype'] = $ctype; } public function getBenefit() { return $this->benefit; } public function setBenefit($benefit) { $this->benefit = $benefit; $this->bizContentarr['benefit'] = $benefit; } public function getExtTags() { return $this->extTags; } public function setExtTags($extTags) { $this->extTags = $extTags; $this->bizContentarr['ext_tags'] = $extTags; } public function getLoginIds() { return $this->loginIds; } public function setLoginIds($loginIds) { $this->loginIds = $loginIds; $this->bizContentarr['login_ids'] = $loginIds; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Model/AlipayOpenPublicMessageTotalSendContentBuilder.php
src/OpenPublic/Model/AlipayOpenPublicMessageTotalSendContentBuilder.php
<?php namespace EasyAlipay\OpenPublic\Model; /* * * 功能:alipay.open.public.message.total.send (群发消息)业务参数封装,详见:https://docs.open.alipay.com/api_6/alipay.open.public.message.total.send */ class AlipayOpenPublicMessageTotalSendContentBuilder { // 消息类型,text:文本消息,image-text:图文消息 private $msgType; // 图文消息,当msg_type为image-text,该值必须设置 private $articles; // 文本消息内容,当msg_type为text,必须设置该值 private $text; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getMsgType() { return $this->msgType; } public function setMsgType($msgType) { $this->msgType = $msgType; $this->bizContentarr['msg_type'] = $msgType; } public function getArticles() { return $this->articles; } public function setArticles($articles) { $this->articles = $articles; $this->bizContentarr['articles'] = $articles; } public function getText() { return $this->text; } public function setText($text) { $this->text = $text; $this->bizContentarr['text'] = $text; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Model/AlipayOpenPublicMessageContentModifyContentBuilder.php
src/OpenPublic/Model/AlipayOpenPublicMessageContentModifyContentBuilder.php
<?php namespace EasyAlipay\OpenPublic\Model; /* * * 功能:alipay.open.public.message.content.modify (更新图文消息内容接口)业务参数封装 */ class AlipayOpenPublicMessageContentModifyContentBuilder { // 内容id private $contentId; // 标题 private $title; // 封面图url, 尺寸为996*450,最大不超过3M,支持格式:.jpg、.png ,请先调用图片上传接口(https://docs.open.alipay.com/api_3/alipay.offline.material.image.upload)获得图片url private $cover; // 消息正文(支持富文本) private $content; // 是否允许评论 T:允许 F:不允许,默认不允许 private $couldComment; // 图文类型 activity: 活动图文,不填默认普通图文 private $ctype; // 活动利益点,图文类型ctype为activity类型时才需要传,最多10个字符 private $benefit; // 关键词列表,英文逗号分隔,最多不超过5个 private $extTags; // 可预览支付宝账号列表,需要预览时才填写,英文逗号分隔,最多不超过10个 private $loginIds; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getContentId() { return $this->contentId; } public function setContentId($contentId) { $this->contentId = $contentId; $this->bizContentarr['content_id'] = $contentId; } public function getTitle() { return $this->title; } public function setTitle($title) { $this->title = $title; $this->bizContentarr['title'] = $title; } public function getCover() { return $this->cover; } public function setCover($cover) { $this->cover = $cover; $this->bizContentarr['cover'] = $cover; } public function getContent() { return $this->content; } public function setContent($content) { $this->content = $content; $this->bizContentarr['content'] = $content; } public function getCouldComment() { return $this->couldComment; } public function setCouldComment($couldComment) { $this->couldComment = $couldComment; $this->bizContentarr['could_comment'] = $couldComment; } public function getCtype() { return $this->ctype; } public function setCtype($ctype) { $this->ctype = $ctype; $this->bizContentarr['ctype'] = $ctype; } public function getBenefit() { return $this->benefit; } public function setBenefit($benefit) { $this->benefit = $benefit; $this->bizContentarr['benefit'] = $benefit; } public function getExtTags() { return $this->extTags; } public function setExtTags($extTags) { $this->extTags = $extTags; $this->bizContentarr['ext_tags'] = $extTags; } public function getLoginIds() { return $this->loginIds; } public function setLoginIds($loginIds) { $this->loginIds = $loginIds; $this->bizContentarr['login_ids'] = $loginIds; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Model/AlipayOpenPublicTemplateMessageIndustryModifyContentBuilder.php
src/OpenPublic/Model/AlipayOpenPublicTemplateMessageIndustryModifyContentBuilder.php
<?php namespace EasyAlipay\OpenPublic\Model; /* * * 功能:alipay.open.public.template.message.industry.modify(模板消息行业设置修改接口)业务参数封装 */ class AlipayOpenPublicTemplateMessageIndustryModifyContentBuilder { // 服务窗消息模板所属主行业一/二级名称,查看行业信息:https://alipay.open.taobao.com/doc2/detail?treeId=197&docType=1&articleId=105043 private $primaryIndustryName; // 服务窗消息模板所属主行业一/二级编码 private $primaryIndustryCode; // 服务窗消息模板所属副行业一/二级编码 private $secondaryIndustryCode; // 服务窗消息模板所属副行业一/二级名称 private $secondaryIndustryName; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getPrimaryIndustryName() { return $this->primaryIndustryName; } public function setPrimaryIndustryName($primaryIndustryName) { $this->primaryIndustryName = $primaryIndustryName; $this->bizContentarr['primary_industry_name'] = $primaryIndustryName; } public function getPrimaryIndustryCode() { return $this->primaryIndustryCode; } public function setPrimaryIndustryCode($primaryIndustryCode) { $this->primaryIndustryCode = $primaryIndustryCode; $this->bizContentarr['primary_industry_code'] = $primaryIndustryCode; } public function getSecondaryIndustryCode() { return $this->secondaryIndustryCode; } public function setSecondaryIndustryCode($secondaryIndustryCode) { $this->secondaryIndustryCode = $secondaryIndustryCode; $this->bizContentarr['secondary_industry_code'] = $secondaryIndustryCode; } public function getSecondaryIndustryName() { return $this->secondaryIndustryName; } public function setSecondaryIndustryName($secondaryIndustryName) { $this->secondaryIndustryName = $secondaryIndustryName; $this->bizContentarr['secondary_industry_name'] = $secondaryIndustryName; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Model/AlipayOpenPublicMessageQueryContentBuilder.php
src/OpenPublic/Model/AlipayOpenPublicMessageQueryContentBuilder.php
<?php namespace EasyAlipay\OpenPublic\Model; /* * * 功能:alipay.open.public.message.query(生活号查询已发送消息接口)业务参数封装 */ class AlipayOpenPublicMessageQueryContentBuilder { // 消息id集,限制最多传入20个message_id。message_id在调用群发、组发消息接口时会返回,需调用方保存 private $messageIds; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getMessageIds() { return $this->messageIds; } public function setMessageIds($messageIds) { $this->messageIds = $messageIds; $this->bizContentarr['message_ids'] = $messageIds; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Template/Client.php
src/OpenPublic/Template/Client.php
<?php namespace EasyAlipay\OpenPublic\Template; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\OpenPublic\Model\AlipayOpenPublicTemplateMessageGetContentBuilder; use EasyAlipay\OpenPublic\Model\AlipayOpenPublicTemplateMessageIndustryModifyContentBuilder; class Client extends AopClient { public function setIndustry(string $primary_industry_name,string $primary_industry_code,string $secondary_industry_code,string $secondary_industry_name) { //构造查询业务请求参数对象 $industryModifyContentBuilder = new AlipayOpenPublicTemplateMessageIndustryModifyContentBuilder(); $industryModifyContentBuilder->setPrimaryIndustryName($primary_industry_name); $industryModifyContentBuilder->setPrimaryIndustryCode($primary_industry_code); $industryModifyContentBuilder->setSecondaryIndustryCode($secondary_industry_code); $industryModifyContentBuilder->setSecondaryIndustryName($secondary_industry_name); $request = new AopRequest (); $request->setBizContent($industryModifyContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.public.template.message.industry.modify"); return($this->execute($request, NULL, NULL)) ; } public function getIndustry() { //构造查询业务请求参数对象 $request = new AopRequest (); $request->setApiMethodName("alipay.open.public.setting.category.query"); return($this->execute($request, NULL, NULL)) ; } public function getTemplate(string $template_id) { //构造查询业务请求参数对象 $getContentBuilder = new AlipayOpenPublicTemplateMessageGetContentBuilder(); $getContentBuilder->setTemplateId($template_id); $request = new AopRequest (); $request->setBizContent($getContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.public.template.message.get"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Template/ServiceProvider.php
src/OpenPublic/Template/ServiceProvider.php
<?php namespace EasyAlipay\OpenPublic\Template; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['template'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Message/Client.php
src/OpenPublic/Message/Client.php
<?php namespace EasyAlipay\OpenPublic\Message; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\OpenPublic\Model\AlipayOpenPublicMessageContentCreateContentBuilder; use EasyAlipay\OpenPublic\Model\AlipayOpenPublicMessageContentModifyContentBuilder; use EasyAlipay\OpenPublic\Model\AlipayOpenPublicMessageTotalSendContentBuilder; use EasyAlipay\OpenPublic\Model\AlipayOpenPublicMessageQueryContentBuilder; use EasyAlipay\OpenPublic\Model\AlipayOpenPublicLifeMsgRecallContentBuilder; class Client extends AopClient { public function createImageTextContent(string $title,string $cover,string $content,string $could_comment,string $ctype,string $benefit,string $ext_tags,string $login_ids) { //构造查询业务请求参数对象 $createContentBuilder = new AlipayOpenPublicMessageContentCreateContentBuilder(); $createContentBuilder->setTitle($title); $createContentBuilder->setCover($cover); $createContentBuilder->setContent($content); $createContentBuilder->setCouldComment($could_comment); $createContentBuilder->setCtype($ctype); $createContentBuilder->setBenefit($benefit); $createContentBuilder->setExtTags($ext_tags); $createContentBuilder->setLoginIds($login_ids); $request = new AopRequest (); $request->setBizContent($createContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.public.message.content.create"); return($this->execute($request, NULL, NULL)) ; } public function modifyImageTextContent(string $content_id,string $title,string $cover,string $content,string $could_comment,string $ctype,string $benefit,string $ext_tags,string $login_ids) { //构造查询业务请求参数对象 $modifyContentBuilder = new AlipayOpenPublicMessageContentModifyContentBuilder(); $modifyContentBuilder->setContentId($content_id); $modifyContentBuilder->setCover($cover); $modifyContentBuilder->setContent($content); $modifyContentBuilder->setCouldComment($could_comment); $modifyContentBuilder->setCtype($ctype); $modifyContentBuilder->setBenefit($benefit); $modifyContentBuilder->setExtTags($ext_tags); $modifyContentBuilder->setLoginIds($login_ids); $request = new AopRequest (); $request->setBizContent($modifyContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.public.message.content.modify"); return($this->execute($request, NULL, NULL)) ; } public function sendText(string $text) { //构造查询业务请求参数对象 $totalSendContentBuilder = new AlipayOpenPublicMessageTotalSendContentBuilder(); $totalSendContentBuilder->setText($text); $totalSendContentBuilder->setMsgType("text"); $request = new AopRequest (); $request->setBizContent($totalSendContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.public.message.total.send"); return($this->execute($request, NULL, NULL)) ; } public function sendImageText(string $articles) { //构造查询业务请求参数对象 $totalSendContentBuilder = new AlipayOpenPublicMessageTotalSendContentBuilder(); $totalSendContentBuilder->setArticles($articles); $totalSendContentBuilder->setMsgType("image-text"); $request = new AopRequest (); $request->setBizContent($totalSendContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.public.message.total.send"); return($this->execute($request, NULL, NULL)) ; } public function query(string $message_ids) { //构造查询业务请求参数对象 $queryContentBuilder = new AlipayOpenPublicMessageQueryContentBuilder(); $queryContentBuilder->setMessageIds($message_ids); $request = new AopRequest (); $request->setBizContent($queryContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.public.message.query"); return($this->execute($request, NULL, NULL)) ; } public function recall(string $message_id) { //构造查询业务请求参数对象 $recallContentBuilder = new AlipayOpenPublicLifeMsgRecallContentBuilder(); $recallContentBuilder->setMessageId($message_id); $request = new AopRequest (); $request->setBizContent($recallContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.public.life.msg.recall"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/OpenPublic/Message/ServiceProvider.php
src/OpenPublic/Message/ServiceProvider.php
<?php namespace EasyAlipay\OpenPublic\Message; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['message'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Kernel/AopClient.php
src/Kernel/AopClient.php
<?php namespace EasyAlipay\Kernel; use Exception; use EasyAlipay\Kernel\SignData; class AopClient { //应用ID private $appId; //商户私钥值 private $rsaPrivateKey; //支付宝公钥值 private $alipayrsaPublicKey; //网关 private $gatewayUrl = "https://openapi.alipay.com/gateway.do"; //返回数据格式 private $format = "json"; //签名类型 private $signType = "RSA"; // 表单提交字符集编码 private $postCharset = "UTF-8"; //api版本 private $apiVersion = "1.0"; //私钥文件路径 private $rsaPrivateKeyFilePath; private $alipayPublicKey = null; private $debugInfo = false; private $fileCharset = "UTF-8"; private $RESPONSE_SUFFIX = "_response"; private $ERROR_RESPONSE = "error_response"; private $SIGN_NODE_NAME = "sign"; //加密XML节点名称 private $ENCRYPT_XML_NODE_NAME = "response_encrypted"; //加密密钥和类型 private $encryptKey; private $needEncrypt = false; private $encryptType = "AES"; protected $alipaySdkVersion = "alipay-sdk-php-easyalipay-20190820"; public function __construct(ServiceContainer $app){ $this->appId = $app['config']['app_id']; $this->rsaPrivateKey = $app['config']['merchant_private_key']; $this->alipayrsaPublicKey = $app['config']['alipay_public_key']; $this->postCharset = $app['config']['charset']; $this->signType=$app['config']['sign_type']; $this->gatewayUrl = $app['config']['gateway_url']; if(empty($this->appId)||trim($this->appId)==""){ throw new Exception("appId should not be NULL!"); } if(empty($this->rsaPrivateKey)||trim($this->rsaPrivateKey)==""){ throw new Exception("rsaPrivateKey should not be NULL!"); } if(empty($this->alipayrsaPublicKey)||trim($this->alipayrsaPublicKey)==""){ throw new Exception("alipayPublicKey should not be NULL!"); } if(empty($this->postCharset)||trim($this->postCharset)==""){ throw new Exception("postCharset should not be NULL!"); } if(empty($this->signType)||trim($this->signType)==""){ throw new Exception("signType should not be NULL!"); } if(empty($this->gatewayUrl)||trim($this->gatewayUrl)==""){ throw new Exception("gatewayUrl should not be NULL!"); } } public function execute($request, $authToken = null, $appInfoAuthtoken = null) { $this->setupCharsets($request); //如果两者编码不一致,会出现签名验签或者乱码 if (strcasecmp($this->fileCharset, $this->postCharset)) { // writeLog("本地文件字符集编码与表单提交编码不一致,请务必设置成一样,属性名分别为postCharset!"); throw new Exception("文件编码:[" . $this->fileCharset . "] 与表单提交编码:[" . $this->postCharset . "]两者不一致!"); } $iv = null; if (!$this->checkEmpty($request->getApiVersion())) { $iv = $request->getApiVersion(); } else { $iv = $this->apiVersion; } //组装系统参数 $sysParams["app_id"] = $this->appId; $sysParams["version"] = $iv; $sysParams["format"] = $this->format; $sysParams["sign_type"] = $this->signType; $sysParams["method"] = $request->getApiMethodName(); $sysParams["timestamp"] = date("Y-m-d H:i:s"); $sysParams["auth_token"] = $authToken; $sysParams["alipay_sdk"] = $this->alipaySdkVersion; $sysParams["terminal_type"] = $request->getTerminalType(); $sysParams["terminal_info"] = $request->getTerminalInfo(); $sysParams["prod_code"] = $request->getProdCode(); $sysParams["notify_url"] = $request->getNotifyUrl(); $sysParams["charset"] = $this->postCharset; $sysParams["app_auth_token"] = $appInfoAuthtoken; //获取业务参数 $apiParams = $request->getApiParas(); if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){ $sysParams["encrypt_type"] = $this->encryptType; if ($this->checkEmpty($apiParams['biz_content'])) { throw new Exception(" api request Fail! The reason : encrypt request is not supperted!"); } if ($this->checkEmpty($this->encryptKey) || $this->checkEmpty($this->encryptType)) { throw new Exception(" encryptType and encryptKey must not null! "); } if ("AES" != $this->encryptType) { throw new Exception("加密类型只支持AES"); } // 执行加密 $enCryptContent = encrypt($apiParams['biz_content'], $this->encryptKey); $apiParams['biz_content'] = $enCryptContent; } //签名 $sysParams["sign"] = $this->generateSign(array_merge($apiParams, $sysParams), $this->signType); //系统参数放入GET请求串 $requestUrl = $this->gatewayUrl . "?"; foreach ($sysParams as $sysParamKey => $sysParamValue) { $requestUrl .= "$sysParamKey=" . urlencode($this->characet($sysParamValue, $this->postCharset)) . "&"; } $requestUrl = substr($requestUrl, 0, -1); //发起HTTP请求 try { $resp = $this->curl($requestUrl, $apiParams); } catch (Exception $e) { var_dump("HTTP_ERROR_" . $e->getCode(), $e->getMessage()); return false; } //解析AOP返回结果 $respWellFormed = false; // 将返回结果转换本地文件编码 $r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp); $signData = null; if ("json" == $this->format) { $respObject = json_decode($r); if (null !== $respObject) { $respWellFormed = true; $signData = $this->parserJSONSignData($request, $resp, $respObject); } } else if ("xml" == $this->format) { $disableLibxmlEntityLoader = libxml_disable_entity_loader(true); $respObject = @ simplexml_load_string($resp); if (false !== $respObject) { $respWellFormed = true; $signData = $this->parserXMLSignData($request, $resp); } libxml_disable_entity_loader($disableLibxmlEntityLoader); } //返回的HTTP文本不是标准JSON或者XML,记下错误日志 if (false === $respWellFormed) { var_dump("HTTP_RESPONSE_NOT_WELL_FORMED_".$resp); return false; } // 验签 $this->checkResponseSign($request, $signData, $resp, $respObject); // 解密 if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){ if ("json" == $this->format) { $resp = $this->encryptJSONSignSource($request, $resp); // 将返回结果转换本地文件编码 $r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp); $respObject = json_decode($r); }else{ $resp = $this->encryptXMLSignSource($request, $resp); $r = iconv($this->postCharset, $this->fileCharset . "//IGNORE", $resp); $disableLibxmlEntityLoader = libxml_disable_entity_loader(true); $respObject = @ simplexml_load_string($r); libxml_disable_entity_loader($disableLibxmlEntityLoader); } } return $respObject; } /** * 生成用于调用收银台SDK的字符串 * @param $request SDK接口的请求参数对象 * @param $appAuthToken 三方应用授权token * @return string * @author guofa.tgf */ public function sdkExecute($request, $appAuthToken = null) { $this->setupCharsets($request); $params['app_id'] = $this->appId; $params['method'] = $request->getApiMethodName(); $params['format'] = $this->format; $params['sign_type'] = $this->signType; $params['timestamp'] = date("Y-m-d H:i:s"); $params['alipay_sdk'] = $this->alipaySdkVersion; $params['charset'] = $this->postCharset; $version = $request->getApiVersion(); $params['version'] = $this->checkEmpty($version) ? $this->apiVersion : $version; if ($notify_url = $request->getNotifyUrl()) { $params['notify_url'] = $notify_url; } $params['app_auth_token'] = $appAuthToken; $dict = $request->getApiParas(); $params['biz_content'] = $dict['biz_content']; ksort($params); $params['sign'] = $this->generateSign($params, $this->signType); foreach ($params as &$value) { $value = $this->characet($value, $params['charset']); } return http_build_query($params); } /** * 页面提交执行方法 * @param $request 跳转类接口的request * @param string $httpmethod 提交方式,两个值可选:post、get; * @param null $appAuthToken 三方应用授权token * @return 构建好的、签名后的最终跳转URL(GET)或String形式的form(POST) * @throws Exception */ public function pageExecute($request, $httpmethod = "POST", $appAuthToken = null) { $this->setupCharsets($request); if (strcasecmp($this->fileCharset, $this->postCharset)) { // writeLog("本地文件字符集编码与表单提交编码不一致,请务必设置成一样,属性名分别为postCharset!"); throw new Exception("文件编码:[" . $this->fileCharset . "] 与表单提交编码:[" . $this->postCharset . "]两者不一致!"); } $iv=null; if(!$this->checkEmpty($request->getApiVersion())){ $iv=$request->getApiVersion(); }else{ $iv=$this->apiVersion; } //组装系统参数 $sysParams["app_id"] = $this->appId; $sysParams["version"] = $iv; $sysParams["format"] = $this->format; $sysParams["sign_type"] = $this->signType; $sysParams["method"] = $request->getApiMethodName(); $sysParams["timestamp"] = date("Y-m-d H:i:s"); $sysParams["alipay_sdk"] = $this->alipaySdkVersion; $sysParams["terminal_type"] = $request->getTerminalType(); $sysParams["terminal_info"] = $request->getTerminalInfo(); $sysParams["prod_code"] = $request->getProdCode(); $sysParams["notify_url"] = $request->getNotifyUrl(); $sysParams["return_url"] = $request->getReturnUrl(); $sysParams["charset"] = $this->postCharset; $sysParams["app_auth_token"] = $appAuthToken; //获取业务参数 $apiParams = $request->getApiParas(); if (method_exists($request,"getNeedEncrypt") &&$request->getNeedEncrypt()){ $sysParams["encrypt_type"] = $this->encryptType; if ($this->checkEmpty($apiParams['biz_content'])) { throw new Exception(" api request Fail! The reason : encrypt request is not supperted!"); } if ($this->checkEmpty($this->encryptKey) || $this->checkEmpty($this->encryptType)) { throw new Exception(" encryptType and encryptKey must not null! "); } if ("AES" != $this->encryptType) { throw new Exception("加密类型只支持AES"); } // 执行加密 $enCryptContent = encrypt($apiParams['biz_content'], $this->encryptKey); $apiParams['biz_content'] = $enCryptContent; } $totalParams = array_merge($apiParams, $sysParams); //待签名字符串 $preSignStr = $this->getSignContent($totalParams); //签名 $totalParams["sign"] = $this->generateSign($totalParams, $this->signType); if ("GET" == strtoupper($httpmethod)) { //value做urlencode $preString=$this->getSignContentUrlencode($totalParams); //拼接GET请求串 $requestUrl = $this->gatewayUrl."?".$preString; return $requestUrl; } else { //拼接表单字符串 return $this->buildRequestForm($totalParams); } } public function generateSign($params, $signType = "RSA") { return $this->sign($this->getSignContent($params), $signType); } public function rsaSign($params, $signType = "RSA") { return $this->sign($this->getSignContent($params), $signType); } public function getSignContent($params) { ksort($params); $stringToBeSigned = ""; $i = 0; foreach ($params as $k => $v) { if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) { // 转换成目标字符集 $v = $this->characet($v, $this->postCharset); if ($i == 0) { $stringToBeSigned .= "$k" . "=" . "$v"; } else { $stringToBeSigned .= "&" . "$k" . "=" . "$v"; } $i++; } } unset ($k, $v); return $stringToBeSigned; } //此方法对value做urlencode public function getSignContentUrlencode($params) { ksort($params); $stringToBeSigned = ""; $i = 0; foreach ($params as $k => $v) { if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) { // 转换成目标字符集 $v = $this->characet($v, $this->postCharset); if ($i == 0) { $stringToBeSigned .= "$k" . "=" . urlencode($v); } else { $stringToBeSigned .= "&" . "$k" . "=" . urlencode($v); } $i++; } } unset ($k, $v); return $stringToBeSigned; } protected function sign($data, $signType = "RSA") { if($this->checkEmpty($this->rsaPrivateKeyFilePath)){ $priKey=$this->rsaPrivateKey; $res = "-----BEGIN RSA PRIVATE KEY-----\n" . wordwrap($priKey, 64, "\n", true) . "\n-----END RSA PRIVATE KEY-----"; }else { $priKey = file_get_contents($this->rsaPrivateKeyFilePath); $res = openssl_get_privatekey($priKey); } ($res) or die('您使用的私钥格式错误,请检查RSA私钥配置'); if ("RSA2" == $signType) { openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256); } else { openssl_sign($data, $sign, $res); } if(!$this->checkEmpty($this->rsaPrivateKeyFilePath)){ openssl_free_key($res); } $sign = base64_encode($sign); return $sign; } /** * RSA单独签名方法,未做字符串处理,字符串处理见getSignContent() * @param $data 待签名字符串 * @param $privatekey 商户私钥,根据keyfromfile来判断是读取字符串还是读取文件,false:填写私钥字符串去回车和空格 true:填写私钥文件路径 * @param $signType 签名方式,RSA:SHA1 RSA2:SHA256 * @param $keyfromfile 私钥获取方式,读取字符串还是读文件 * @return string * @author mengyu.wh */ public function alonersaSign($data,$privatekey,$signType = "RSA",$keyfromfile=false) { if(!$keyfromfile){ $priKey=$privatekey; $res = "-----BEGIN RSA PRIVATE KEY-----\n" . wordwrap($priKey, 64, "\n", true) . "\n-----END RSA PRIVATE KEY-----"; } else{ $priKey = file_get_contents($privatekey); $res = openssl_get_privatekey($priKey); } ($res) or die('您使用的私钥格式错误,请检查RSA私钥配置'); if ("RSA2" == $signType) { openssl_sign($data, $sign, $res, OPENSSL_ALGO_SHA256); } else { openssl_sign($data, $sign, $res); } if($keyfromfile){ openssl_free_key($res); } $sign = base64_encode($sign); return $sign; } protected function curl($url, $postFields = null) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); $postBodyString = ""; $encodeArray = Array(); $postMultipart = false; if (is_array($postFields) && 0 < count($postFields)) { foreach ($postFields as $k => $v) { if ("@" != substr($v, 0, 1)) //判断是不是文件上传 { $postBodyString .= "$k=" . urlencode($this->characet($v, $this->postCharset)) . "&"; $encodeArray[$k] = $this->characet($v, $this->postCharset); } else //文件上传用multipart/form-data,否则用www-form-urlencoded { $postMultipart = true; $encodeArray[$k] = new \CURLFile(substr($v, 1)); } } unset ($k, $v); curl_setopt($ch, CURLOPT_POST, true); if ($postMultipart) { curl_setopt($ch, CURLOPT_POSTFIELDS, $encodeArray); } else { curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString, 0, -1)); } } if ($postMultipart) { $headers = array('content-type: multipart/form-data;charset=' . $this->postCharset . ';boundary=' . $this->getMillisecond()); } else { $headers = array('content-type: application/x-www-form-urlencoded;charset=' . $this->postCharset); } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $reponse = curl_exec($ch); if (curl_errno($ch)) { throw new Exception(curl_error($ch), 0); } else { $httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if (200 !== $httpStatusCode) { throw new Exception($reponse, $httpStatusCode); } } curl_close($ch); return $reponse; } protected function getMillisecond() { list($s1, $s2) = explode(' ', microtime()); return (float)sprintf('%.0f', (floatval($s1) + floatval($s2)) * 1000); } protected function logCommunicationError($apiName, $requestUrl, $errorCode, $responseTxt) { $localIp = isset ($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : "CLI"; $logger = new LtLogger; $logger->conf["log_file"] = rtrim(AOP_SDK_WORK_DIR, '\\/') . '/' . "logs/aop_comm_err_" . $this->appId . "_" . date("Y-m-d") . ".log"; $logger->conf["separator"] = "^_^"; $logData = array( date("Y-m-d H:i:s"), $apiName, $this->appId, $localIp, PHP_OS, $this->alipaySdkVersion, $requestUrl, $errorCode, str_replace("\n", "", $responseTxt) ); $logger->log($logData); } /** * 建立请求,以表单HTML形式构造(默认) * @param $para_temp 请求参数数组 * @return 提交表单HTML文本 */ protected function buildRequestForm($para_temp) { $sHtml = "<form id='alipaysubmit' name='alipaysubmit' action='".$this->gatewayUrl."?charset=".trim($this->postCharset)."' method='POST'>"; while (list ($key, $val) = each ($para_temp)) { if (false === $this->checkEmpty($val)) { //$val = $this->characet($val, $this->postCharset); $val = str_replace("'","&apos;",$val); //$val = str_replace("\"","&quot;",$val); $sHtml.= "<input type='hidden' name='".$key."' value='".$val."'/>"; } } //submit按钮控件请不要含有name属性 $sHtml = $sHtml."<input type='submit' value='ok' style='display:none;''></form>"; $sHtml = $sHtml."<script>document.forms['alipaysubmit'].submit();</script>"; return $sHtml; } /** * 转换字符集编码 * @param $data * @param $targetCharset * @return string */ function characet($data, $targetCharset) { if (!empty($data)) { $fileType = $this->fileCharset; if (strcasecmp($fileType, $targetCharset) != 0) { $data = mb_convert_encoding($data, $targetCharset, $fileType); // $data = iconv($fileType, $targetCharset.'//IGNORE', $data); } } return $data; } public function exec($paramsArray) { if (!isset ($paramsArray["method"])) { trigger_error("No api name passed"); } $inflector = new LtInflector; $inflector->conf["separator"] = "."; $requestClassName = ucfirst($inflector->camelize(substr($paramsArray["method"], 7))) . "Request"; if (!class_exists($requestClassName)) { trigger_error("No such api: " . $paramsArray["method"]); } $session = isset ($paramsArray["session"]) ? $paramsArray["session"] : null; $req = new $requestClassName; foreach ($paramsArray as $paraKey => $paraValue) { $inflector->conf["separator"] = "_"; $setterMethodName = $inflector->camelize($paraKey); $inflector->conf["separator"] = "."; $setterMethodName = "set" . $inflector->camelize($setterMethodName); if (method_exists($req, $setterMethodName)) { $req->$setterMethodName ($paraValue); } } return $this->execute($req, $session); } /** * 校验$value是否非空 * if not set ,return true; * if is null , return true; **/ protected function checkEmpty($value) { if (!isset($value)) return true; if ($value === null) return true; if (trim($value) === "") return true; return false; } /** rsaCheckV1 & rsaCheckV2 * 验证签名 * 在使用本方法前,必须初始化AopClient且传入公钥参数。 * 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。 **/ public function rsaCheckV1($params, $rsaPublicKeyFilePath,$signType='RSA') { $sign = $params['sign']; $params['sign_type'] = null; $params['sign'] = null; return $this->verify($this->getSignContent($params), $sign, $rsaPublicKeyFilePath,$signType); } public function rsaCheckV2($params, $rsaPublicKeyFilePath, $signType='RSA') { $sign = $params['sign']; $params['sign'] = null; return $this->verify($this->getSignContent($params), $sign, $rsaPublicKeyFilePath, $signType); } function verify($data, $sign, $rsaPublicKeyFilePath, $signType = 'RSA') { if($this->checkEmpty($this->alipayPublicKey)){ $pubKey= $this->alipayrsaPublicKey; $res = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($pubKey, 64, "\n", true) . "\n-----END PUBLIC KEY-----"; }else { //读取公钥文件 $pubKey = file_get_contents($rsaPublicKeyFilePath); //转换为openssl格式密钥 $res = openssl_get_publickey($pubKey); } ($res) or die('支付宝RSA公钥错误。请检查公钥文件格式是否正确'); //调用openssl内置方法验签,返回bool值 $result = FALSE; if ("RSA2" == $signType) { $result = (openssl_verify($data, base64_decode($sign), $res, OPENSSL_ALGO_SHA256)===1); } else { $result = (openssl_verify($data, base64_decode($sign), $res)===1); } if(!$this->checkEmpty($this->alipayPublicKey)) { //释放资源 openssl_free_key($res); } return $result; } /** * 在使用本方法前,必须初始化AopClient且传入公私钥参数。 * 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。 **/ public function checkSignAndDecrypt($params, $rsaPublicKeyPem, $rsaPrivateKeyPem, $isCheckSign, $isDecrypt, $signType='RSA') { $charset = $params['charset']; $bizContent = $params['biz_content']; if ($isCheckSign) { if (!$this->rsaCheckV2($params, $rsaPublicKeyPem, $signType)) { echo "<br/>checkSign failure<br/>"; exit; } } if ($isDecrypt) { return $this->rsaDecrypt($bizContent, $rsaPrivateKeyPem, $charset); } return $bizContent; } /** * 在使用本方法前,必须初始化AopClient且传入公私钥参数。 * 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。 **/ public function encryptAndSign($bizContent, $rsaPublicKeyPem, $rsaPrivateKeyPem, $charset, $isEncrypt, $isSign, $signType='RSA') { // 加密,并签名 if ($isEncrypt && $isSign) { $encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset); $sign = $this->sign($encrypted, $signType); $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>RSA</encryption_type><sign>$sign</sign><sign_type>$signType</sign_type></alipay>"; return $response; } // 加密,不签名 if ($isEncrypt && (!$isSign)) { $encrypted = $this->rsaEncrypt($bizContent, $rsaPublicKeyPem, $charset); $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$encrypted</response><encryption_type>$signType</encryption_type></alipay>"; return $response; } // 不加密,但签名 if ((!$isEncrypt) && $isSign) { $sign = $this->sign($bizContent, $signType); $response = "<?xml version=\"1.0\" encoding=\"$charset\"?><alipay><response>$bizContent</response><sign>$sign</sign><sign_type>$signType</sign_type></alipay>"; return $response; } // 不加密,不签名 $response = "<?xml version=\"1.0\" encoding=\"$charset\"?>$bizContent"; return $response; } /** * 在使用本方法前,必须初始化AopClient且传入公私钥参数。 * 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。 **/ public function rsaEncrypt($data, $rsaPublicKeyPem, $charset) { if($this->checkEmpty($this->alipayPublicKey)){ //读取字符串 $pubKey= $this->alipayrsaPublicKey; $res = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($pubKey, 64, "\n", true) . "\n-----END PUBLIC KEY-----"; }else { //读取公钥文件 $pubKey = file_get_contents($rsaPublicKeyFilePath); //转换为openssl格式密钥 $res = openssl_get_publickey($pubKey); } ($res) or die('支付宝RSA公钥错误。请检查公钥文件格式是否正确'); $blocks = $this->splitCN($data, 0, 30, $charset); $chrtext  = null; $encodes  = array(); foreach ($blocks as $n => $block) { if (!openssl_public_encrypt($block, $chrtext , $res)) { echo "<br/>" . openssl_error_string() . "<br/>"; } $encodes[] = $chrtext ; } $chrtext = implode(",", $encodes); return base64_encode($chrtext); } /** * 在使用本方法前,必须初始化AopClient且传入公私钥参数。 * 公钥是否是读取字符串还是读取文件,是根据初始化传入的值判断的。 **/ public function rsaDecrypt($data, $rsaPrivateKeyPem, $charset) { if($this->checkEmpty($this->rsaPrivateKeyFilePath)){ //读字符串 $priKey=$this->rsaPrivateKey; $res = "-----BEGIN RSA PRIVATE KEY-----\n" . wordwrap($priKey, 64, "\n", true) . "\n-----END RSA PRIVATE KEY-----"; }else { $priKey = file_get_contents($this->rsaPrivateKeyFilePath); $res = openssl_get_privatekey($priKey); } ($res) or die('您使用的私钥格式错误,请检查RSA私钥配置'); //转换为openssl格式密钥 $decodes = explode(',', $data); $strnull = ""; $dcyCont = ""; foreach ($decodes as $n => $decode) { if (!openssl_private_decrypt($decode, $dcyCont, $res)) { echo "<br/>" . openssl_error_string() . "<br/>"; } $strnull .= $dcyCont; } return $strnull; } function splitCN($cont, $n = 0, $subnum, $charset) { //$len = strlen($cont) / 3; $arrr = array(); for ($i = $n; $i < strlen($cont); $i += $subnum) { $res = $this->subCNchar($cont, $i, $subnum, $charset); if (!empty ($res)) { $arrr[] = $res; } } return $arrr; } function subCNchar($str, $start = 0, $length, $charset = "gbk") { if (strlen($str) <= $length) { return $str; } $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/"; $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/"; $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/"; $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/"; preg_match_all($re[$charset], $str, $match); $slice = join("", array_slice($match[0], $start, $length)); return $slice; } function parserResponseSubCode($request, $responseContent, $respObject, $format) { if ("json" == $format) { $apiName = $request->getApiMethodName(); $rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX; $errorNodeName = $this->ERROR_RESPONSE; $rootIndex = strpos($responseContent, $rootNodeName); $errorIndex = strpos($responseContent, $errorNodeName); if ($rootIndex > 0) { // 内部节点对象 $rInnerObject = $respObject->$rootNodeName; } elseif ($errorIndex > 0) { $rInnerObject = $respObject->$errorNodeName; } else { return null; } // 存在属性则返回对应值 if (isset($rInnerObject->sub_code)) { return $rInnerObject->sub_code; } else { return null; } } elseif ("xml" == $format) { // xml格式sub_code在同一层级 return $respObject->sub_code; } } function parserJSONSignData($request, $responseContent, $responseJSON) { $signData = new SignData(); $signData->sign = $this->parserJSONSign($responseJSON); $signData->signSourceData = $this->parserJSONSignSource($request, $responseContent); return $signData; } function parserJSONSignSource($request, $responseContent) { $apiName = $request->getApiMethodName(); $rootNodeName = str_replace(".", "_", $apiName) . $this->RESPONSE_SUFFIX; $rootIndex = strpos($responseContent, $rootNodeName); $errorIndex = strpos($responseContent, $this->ERROR_RESPONSE); if ($rootIndex > 0) { return $this->parserJSONSource($responseContent, $rootNodeName, $rootIndex); } else if ($errorIndex > 0) { return $this->parserJSONSource($responseContent, $this->ERROR_RESPONSE, $errorIndex); } else { return null; } } function parserJSONSource($responseContent, $nodeName, $nodeIndex) { $signDataStartIndex = $nodeIndex + strlen($nodeName) + 2; $signIndex = strrpos($responseContent, "\"" . $this->SIGN_NODE_NAME . "\""); // 签名前-逗号 $signDataEndIndex = $signIndex - 1; $indexLen = $signDataEndIndex - $signDataStartIndex; if ($indexLen < 0) { return null; } return substr($responseContent, $signDataStartIndex, $indexLen); } function parserJSONSign($responseJSon) { return $responseJSon->sign; }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
true
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Kernel/SignData.php
src/Kernel/SignData.php
<?php namespace EasyAlipay\Kernel; class SignData { public $signSourceData=null; public $sign=null; }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Kernel/AopRequest.php
src/Kernel/AopRequest.php
<?php namespace EasyAlipay\Kernel; class AopRequest { private $apiMethodName; private $bizContent; private $apiParas = array(); private $terminalType; private $terminalInfo; private $prodCode; private $apiVersion="1.0"; private $notifyUrl; private $returnUrl; private $needEncrypt=false; public function getApiMethodName() { return $this->apiMethodName; } public function setApiMethodName($apiMethodName) { $this->apiMethodName=$apiMethodName; } public function setBizContent($bizContent) { $this->bizContent = $bizContent; $this->apiParas["biz_content"] = $bizContent; } public function getBizContent() { return $this->bizContent; } public function setNotifyUrl($notifyUrl) { $this->notifyUrl=$notifyUrl; } public function getNotifyUrl() { return $this->notifyUrl; } public function setReturnUrl($returnUrl) { $this->returnUrl=$returnUrl; } public function getReturnUrl() { return $this->returnUrl; } public function getApiParas() { return $this->apiParas; } public function getTerminalType() { return $this->terminalType; } public function setTerminalType($terminalType) { $this->terminalType = $terminalType; } public function getTerminalInfo() { return $this->terminalInfo; } public function setTerminalInfo($terminalInfo) { $this->terminalInfo = $terminalInfo; } public function getProdCode() { return $this->prodCode; } public function setProdCode($prodCode) { $this->prodCode = $prodCode; } public function setApiVersion($apiVersion) { $this->apiVersion=$apiVersion; } public function getApiVersion() { return $this->apiVersion; } public function setNeedEncrypt($needEncrypt) { $this->needEncrypt=$needEncrypt; } public function getNeedEncrypt() { return $this->needEncrypt; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Kernel/Config.php
src/Kernel/Config.php
<?php namespace EasyAlipay\Kernel; class Config { public $config = [ //应用ID 'app_id' => '', //支付宝公钥 'alipay_public_key' => '', //商户私钥 'merchant_private_key' => '', //网管地址 'gateway_url' => "https://openapi.alipay.com/gateway.do", //异步通知地址 'notify_url' => "", //同步跳转 'return_url' => "", //编码格式 'charset' => "UTF-8", //签名方式,默认为RSA2(RSA2048) 'sign_type' =>"RSA2", // ... ]; }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Kernel/ServiceContainer.php
src/Kernel/ServiceContainer.php
<?php namespace EasyAlipay\Kernel; use EasyAlipay\Kernel\Config; use EasyAlipay\Kernel\Providers\ConfigServiceProvider; use Pimple\Container; /** * Class ServiceContainer * * @property \EasyAlipay\Kernel\Config $config */ class ServiceContainer extends Container { /** * @var array */ protected $providers = []; /** * @var array */ protected $defaultConfig = []; /** * @var array */ protected $userConfig = []; /** * Constructor. * * @param array $config */ public function __construct(array $config = []) { $this->registerProviders($this->getProviders()); parent::__construct(); $this->userConfig = $config; $config = new config(); $this->defaultConfig = $config->config; } public function getConfig() { return array_replace_recursive($this->defaultConfig, $this->userConfig); } /** * Return all providers. * * @return array */ public function getProviders() { return array_merge([ ConfigServiceProvider::class, ], $this->providers); } /** * @param array $providers */ public function registerProviders(array $providers) { foreach ($providers as $provider) { parent::register(new $provider()); } } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Kernel/Traits/HasHttpRequests.php
src/Kernel/Traits/HasHttpRequests.php
<?php namespace EasyAlipay\Kernel\Traits; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\HandlerStack; use Psr\Http\Message\ResponseInterface; trait HasHttpRequests { use ResponseCastable; /** * @var \GuzzleHttp\ClientInterface */ protected $httpClient; /** * @var array */ protected $middlewares = []; /** * @var \GuzzleHttp\HandlerStack */ protected $handlerStack; /** * @var array */ protected static $defaults = [ 'curl' => [ CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4, ], ]; /** * Set guzzle default settings. * * @param array $defaults */ public static function setDefaultOptions($defaults = []) { self::$defaults = $defaults; } /** * Return current guzzle default settings. * * @return array */ public static function getDefaultOptions(): array { return self::$defaults; } /** * Set GuzzleHttp\Client. * * @param \GuzzleHttp\ClientInterface $httpClient * * @return $this */ public function setHttpClient(ClientInterface $httpClient) { $this->httpClient = $httpClient; return $this; } /** * Return GuzzleHttp\ClientInterface instance. * * @return ClientInterface */ public function getHttpClient(): ClientInterface { if (!($this->httpClient instanceof ClientInterface)) { if (property_exists($this, 'app') && $this->app['http_client']) { $this->httpClient = $this->app['http_client']; } else { $this->httpClient = new Client(['handler' => HandlerStack::create($this->getGuzzleHandler())]); } } return $this->httpClient; } /** * Add a middleware. * * @param callable $middleware * @param string|null $name * * @return $this */ public function pushMiddleware(callable $middleware, string $name = null) { if (!is_null($name)) { $this->middlewares[$name] = $middleware; } else { array_push($this->middlewares, $middleware); } return $this; } /** * Return all middlewares. * * @return array */ public function getMiddlewares(): array { return $this->middlewares; } /** * Make a request. * * @param string $url * @param string $method * @param array $options * * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string */ public function request($url, $method = 'GET', $options = []): ResponseInterface { $method = strtoupper($method); $options = array_merge(self::$defaults, $options, ['handler' => $this->getHandlerStack()]); $options = $this->fixJsonIssue($options); if (property_exists($this, 'baseUri') && !is_null($this->baseUri)) { $options['base_uri'] = $this->baseUri; } $response = $this->getHttpClient()->request($method, $url, $options); $response->getBody()->rewind(); return $response; } /** * @param \GuzzleHttp\HandlerStack $handlerStack * * @return $this */ public function setHandlerStack(HandlerStack $handlerStack) { $this->handlerStack = $handlerStack; return $this; } /** * Build a handler stack. * * @return \GuzzleHttp\HandlerStack */ public function getHandlerStack(): HandlerStack { if ($this->handlerStack) { return $this->handlerStack; } $this->handlerStack = HandlerStack::create($this->getGuzzleHandler()); foreach ($this->middlewares as $name => $middleware) { $this->handlerStack->push($middleware, $name); } return $this->handlerStack; } /** * @param array $options * * @return array */ protected function fixJsonIssue(array $options): array { if (isset($options['json']) && is_array($options['json'])) { $options['headers'] = array_merge($options['headers'] ?? [], ['Content-Type' => 'application/json']); if (empty($options['json'])) { $options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_FORCE_OBJECT); } else { $options['body'] = \GuzzleHttp\json_encode($options['json'], JSON_UNESCAPED_UNICODE); } unset($options['json']); } return $options; } /** * Get guzzle handler. * * @return callable */ protected function getGuzzleHandler() { if (property_exists($this, 'app') && isset($this->app['guzzle_handler']) && is_string($this->app['guzzle_handler'])) { $handler = $this->app['guzzle_handler']; return new $handler(); } return \GuzzleHttp\choose_handler(); } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Kernel/Support/Str.php
src/Kernel/Support/Str.php
<?php namespace EasyAlipay\Kernel\Support; use EasyAlipay\Kernel\Exceptions\RuntimeException; /** * Class Str. */ class Str { /** * The cache of snake-cased words. * * @var array */ protected static $snakeCache = []; /** * The cache of camel-cased words. * * @var array */ protected static $camelCache = []; /** * The cache of studly-cased words. * * @var array */ protected static $studlyCache = []; /** * Convert a value to camel case. * * @param string $value * * @return string */ public static function camel($value) { if (isset(static::$camelCache[$value])) { return static::$camelCache[$value]; } return static::$camelCache[$value] = lcfirst(static::studly($value)); } /** * Generate a more truly "random" alpha-numeric string. * * @param int $length * * @return string * * @throws \RuntimeException */ public static function random($length = 16) { $string = ''; while (($len = strlen($string)) < $length) { $size = $length - $len; $bytes = static::randomBytes($size); $string .= substr(str_replace(['/', '+', '='], '', base64_encode($bytes)), 0, $size); } return $string; } /** * Generate a more truly "random" bytes. * * @param int $length * * @return string * * @throws RuntimeException * * @codeCoverageIgnore * * @throws \Exception */ public static function randomBytes($length = 16) { if (function_exists('random_bytes')) { $bytes = random_bytes($length); } elseif (function_exists('openssl_random_pseudo_bytes')) { $bytes = openssl_random_pseudo_bytes($length, $strong); if (false === $bytes || false === $strong) { throw new RuntimeException('Unable to generate random string.'); } } else { throw new RuntimeException('OpenSSL extension is required for PHP 5 users.'); } return $bytes; } /** * Generate a "random" alpha-numeric string. * * Should not be considered sufficient for cryptography, etc. * * @param int $length * * @return string */ public static function quickRandom($length = 16) { $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; return substr(str_shuffle(str_repeat($pool, $length)), 0, $length); } /** * Convert the given string to upper-case. * * @param string $value * * @return string */ public static function upper($value) { return mb_strtoupper($value); } /** * Convert the given string to title case. * * @param string $value * * @return string */ public static function title($value) { return mb_convert_case($value, MB_CASE_TITLE, 'UTF-8'); } /** * Convert a string to snake case. * * @param string $value * @param string $delimiter * * @return string */ public static function snake($value, $delimiter = '_') { $key = $value.$delimiter; if (isset(static::$snakeCache[$key])) { return static::$snakeCache[$key]; } if (!ctype_lower($value)) { $value = strtolower(preg_replace('/(.)(?=[A-Z])/', '$1'.$delimiter, $value)); } return static::$snakeCache[$key] = trim($value, '_'); } /** * Convert a value to studly caps case. * * @param string $value * * @return string */ public static function studly($value) { $key = $value; if (isset(static::$studlyCache[$key])) { return static::$studlyCache[$key]; } $value = ucwords(str_replace(['-', '_'], ' ', $value)); return static::$studlyCache[$key] = str_replace(' ', '', $value); } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Kernel/Providers/ConfigServiceProvider.php
src/Kernel/Providers/ConfigServiceProvider.php
<?php namespace EasyAlipay\Kernel\Providers; use EasyAlipay\Kernel\Config; use Pimple\Container; use Pimple\ServiceProviderInterface; class ConfigServiceProvider implements ServiceProviderInterface { /** * Registers services on the given container. * * This method should only be used to configure services and parameters. * It should not get services. * * @param Container $pimple A container instance */ public function register(Container $pimple) { $pimple['config'] = function ($app) { return $app->getConfig(); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Base/Application.php
src/Base/Application.php
<?php namespace EasyAlipay\Base; use EasyAlipay\Kernel\ServiceContainer; /** * Class Application. * * @property \EasyAlipay\Base\Image\Client $image * @property \EasyAlipay\Base\Oauth\Client $oauth * @property \EasyAlipay\Base\Video\Client $video * */ class Application extends ServiceContainer { /** * @var array */ protected $providers = [ Oauth\ServiceProvider::class, ]; }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Base/Model/AlipaySystemOauthTokenRequest.php
src/Base/Model/AlipaySystemOauthTokenRequest.php
<?php namespace EasyAlipay\Base\Model; /* * * 功能:alipay.system.oauth.token(换取授权访问令牌接口)业务参数封装 */ class AlipaySystemOauthTokenRequest { /** * 授权码,用户对应用授权后得到。 **/ private $code; /** * 值为authorization_code时,代表用code换取;值为refresh_token时,代表用refresh_token换取 **/ private $grantType; /** * 刷新令牌,上次换取访问令牌时得到。见出参的refresh_token字段 **/ private $refreshToken; private $apiParas = array(); private $terminalType; private $terminalInfo; private $prodCode; private $apiVersion="1.0"; private $notifyUrl; private $returnUrl; private $needEncrypt=false; public function setCode($code) { $this->code = $code; $this->apiParas["code"] = $code; } public function getCode() { return $this->code; } public function setGrantType($grantType) { $this->grantType = $grantType; $this->apiParas["grant_type"] = $grantType; } public function getGrantType() { return $this->grantType; } public function setRefreshToken($refreshToken) { $this->refreshToken = $refreshToken; $this->apiParas["refresh_token"] = $refreshToken; } public function getRefreshToken() { return $this->refreshToken; } public function getApiMethodName() { return "alipay.system.oauth.token"; } public function setNotifyUrl($notifyUrl) { $this->notifyUrl=$notifyUrl; } public function getNotifyUrl() { return $this->notifyUrl; } public function setReturnUrl($returnUrl) { $this->returnUrl=$returnUrl; } public function getReturnUrl() { return $this->returnUrl; } public function getApiParas() { return $this->apiParas; } public function getTerminalType() { return $this->terminalType; } public function setTerminalType($terminalType) { $this->terminalType = $terminalType; } public function getTerminalInfo() { return $this->terminalInfo; } public function setTerminalInfo($terminalInfo) { $this->terminalInfo = $terminalInfo; } public function getProdCode() { return $this->prodCode; } public function setProdCode($prodCode) { $this->prodCode = $prodCode; } public function setApiVersion($apiVersion) { $this->apiVersion=$apiVersion; } public function getApiVersion() { return $this->apiVersion; } public function setNeedEncrypt($needEncrypt) { $this->needEncrypt=$needEncrypt; } public function getNeedEncrypt() { return $this->needEncrypt; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Base/Oauth/Client.php
src/Base/Oauth/Client.php
<?php namespace EasyAlipay\Base\Oauth; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Base\Model\AlipaySystemOauthTokenRequest; class Client extends AopClient { public function getToken(string $grant_type, string $code, string $refresh_token) { //构造查询业务请求参数对象 $alipaySystemOauthTokenRequest = new AlipaySystemOauthTokenRequest(); $alipaySystemOauthTokenRequest->setGrantType($grant_type); $alipaySystemOauthTokenRequest->setCode($code); $alipaySystemOauthTokenRequest->setRefreshToken($refresh_token); return($this->execute($alipaySystemOauthTokenRequest, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Base/Oauth/ServiceProvider.php
src/Base/Oauth/ServiceProvider.php
<?php namespace EasyAlipay\Base\Oauth; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { /** * {@inheritdoc}. */ public function register(Container $app) { $app['oauth'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Marketing/Application.php
src/Marketing/Application.php
<?php namespace EasyAlipay\Marketing; use EasyAlipay\Kernel\ServiceContainer; /** * Class Application. * * @property \EasyAlipay\Marketing\Pass\Client $pass * */ class Application extends ServiceContainer { /** * @var array */ protected $providers = [ Pass\ServiceProvider::class, ]; }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Marketing/Model/AlipayPassTemplateUpdateContentBuilder.php
src/Marketing/Model/AlipayPassTemplateUpdateContentBuilder.php
<?php namespace EasyAlipay\Marketing\Model; /* * * 功能:alipay.pass.template.update (卡券模板更新接口)业务参数封装 */ class AlipayPassTemplateUpdateContentBuilder { // 商户用于控制模版的唯一性。(可以使用时间戳保证唯一性) private $tplId; // 模板内容信息,遵循JSON规范,详情参见tpl_content参数说明:https://doc.open.alipay.com/doc2/detail.htm?treeId=193&articleId=105249&docType=1#tpl_content private $tplContent; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTplId() { return $this->tplId; } public function setTplId($tplId) { $this->tplId = $tplId; $this->bizContentarr['tpl_id'] = $tplId; } public function getTplContent() { return $this->tplContent; } public function setTplContent($tplContent) { $this->tplContent = $tplContent; $this->bizContentarr['tpl_content'] = $tplContent; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Marketing/Model/AlipayPassTemplateAddContentBuilder.php
src/Marketing/Model/AlipayPassTemplateAddContentBuilder.php
<?php namespace EasyAlipay\Marketing\Model; /* * * 功能:alipay.pass.template.add (卡券模板创建接口)业务参数封装 */ class AlipayPassTemplateAddContentBuilder { // 商户用于控制模版的唯一性。(可以使用时间戳保证唯一性) private $uniqueId; // 模板内容信息,遵循JSON规范,详情参见tpl_content参数说明:https://doc.open.alipay.com/doc2/detail.htm?treeId=193&articleId=105249&docType=1#tpl_content private $tplContent; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getUniqueId() { return $this->uniqueId; } public function setUniqueId($uniqueId) { $this->uniqueId = $uniqueId; $this->bizContentarr['unique_id'] = $uniqueId; } public function getTplContent() { return $this->tplContent; } public function setTplContent($tplContent) { $this->tplContent = $tplContent; $this->bizContentarr['tpl_content'] = $tplContent; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Marketing/Model/AlipayPassInstanceUpdateContentBuilder.php
src/Marketing/Model/AlipayPassInstanceUpdateContentBuilder.php
<?php namespace EasyAlipay\Marketing\Model; /* * * alipay.pass.instance.update(卡券实例更新接口)业务参数封装 */ class AlipayPassInstanceUpdateContentBuilder { // 商户指定卡券唯一值,卡券JSON模板中fileInfo->serialNumber字段对应的值 private $serialNumber; // 代理商代替商户发放卡券后,再代替商户更新卡券时,此值为商户的pid/appid private $channelId; // 模版动态参数信息:对应模板中$变量名$的动态参数,见模板创建接口返回值中的tpl_params字段 private $tplParams; // 券状态,支持更新为USED、CLOSED两种状态 private $status; // 核销码串值【当状态变更为USED时,建议传】。该值正常为模板中核销区域(Operation)对应的message值。 private $verifyCode; // 核销方式,该值正常为模板中核销区域(Operation)对应的format值。verify_code和verify_type需同时传入。 private $verifyType; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getSerialNumber() { return $this->serialNumber; } public function setSerialNumber($serialNumber) { $this->serialNumber = $serialNumber; $this->bizContentarr['serial_number'] = $serialNumber; } public function getChannelId() { return $this->channelId; } public function setChannelId($channelId) { $this->channelId = $channelId; $this->bizContentarr['channel_id'] = $channelId; } public function getTplParams() { return $this->tplParams; } public function setTplParams($tplParams) { $this->tplParams = $tplParams; $this->bizContentarr['tpl_params'] = $tplParams; } public function getStatus() { return $this->status; } public function setStatus($status) { $this->status = $status; $this->bizContentarr['status'] = $status; } public function getVerifyCode() { return $this->verifyCode; } public function setVerifyCode($verifyCode) { $this->verifyCode = $verifyCode; $this->bizContentarr['verify_code'] = $verifyCode; } public function getVerifyType() { return $this->verifyType; } public function setVerifyType($verifyType) { $this->verifyType = $verifyType; $this->bizContentarr['verify_type'] = $verifyType; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Marketing/Model/AlipayPassInstanceAddContentBuilder.php
src/Marketing/Model/AlipayPassInstanceAddContentBuilder.php
<?php namespace EasyAlipay\Marketing\Model; /* * * 功能:alipay.pass.instance.add (卡券实例发放接口)业务参数封装 */ class AlipayPassInstanceAddContentBuilder { // 支付宝pass模版ID,即调用模板创建接口时返回的tpl_id private $tplId; // 模版动态参数信息:对应模板中$变量名$的动态参数,见模板创建接口返回值中的tpl_params字段 private $tplParams; // Alipass添加对象识别类型:1–订单信息 private $recognitionType; // 支付宝用户识别信息:uid发券组件。对接文档:https://docs.open.alipay.com/199/sy3hs4 private $recognitionInfo; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTplId() { return $this->tplId; } public function setTplId($tplId) { $this->tplId = $tplId; $this->bizContentarr['tpl_id'] = $tplId; } public function getTplParams() { return $this->tplParams; } public function setTplParams($tplParams) { $this->tplParams = $tplParams; $this->bizContentarr['tpl_params'] = $tplParams; } public function getRecognitionType() { return $this->recognitionType; } public function setRecognitionType($recognitionType) { $this->recognitionType = $recognitionType; $this->bizContentarr['recognition_type'] = $recognitionType; } public function getRecognitionInfo() { return $this->recognitionInfo; } public function setRecognitionInfo($recognitionInfo) { $this->recognitionInfo = $recognitionInfo; $this->bizContentarr['recognition_info'] = $recognitionInfo; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Marketing/Pass/Client.php
src/Marketing/Pass/Client.php
<?php namespace EasyAlipay\Marketing\Pass; use EasyAlipay\Kernel\Support; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Kernel\Config; use EasyAlipay\Marketing\Model\AlipayPassTemplateAddContentBuilder; use EasyAlipay\Marketing\Model\AlipayPassTemplateUpdateContentBuilder; use EasyAlipay\Marketing\Model\AlipayPassInstanceAddContentBuilder; use EasyAlipay\Marketing\Model\AlipayPassInstanceUpdateContentBuilder; class Client extends AopClient { public function createTemplate(string $unique_id,string $tpl_content) { //构造查询业务请求参数对象 $templateAddContentBuilder = new AlipayPassTemplateAddContentBuilder(); $templateAddContentBuilder->setUniqueId($unique_id); $templateAddContentBuilder->setTplContent($tpl_content); $request = new AopRequest (); $request->setBizContent($templateAddContentBuilder->getBizContent()); $request->setApiMethodName("alipay.pass.template.add"); return($this->execute($request, NULL, NULL)) ; } public function updateTemplate(string $tpl_id,string $tpl_content) { //构造查询业务请求参数对象 $templateUpdateContentBuilder = new AlipayPassTemplateUpdateContentBuilder(); $templateUpdateContentBuilder->setTplId($tpl_id); $templateUpdateContentBuilder->setTplContent($tpl_content); $request = new AopRequest (); $request->setBizContent($templateUpdateContentBuilder->getBizContent()); $request->setApiMethodName("alipay.pass.template.update"); return($this->execute($request, NULL, NULL)) ; } public function addInstance(string $tpl_id,string $tpl_params,string $recognition_type,string $recognition_info) { //构造查询业务请求参数对象 $addInstanceContentBuilder = new AlipayPassInstanceAddContentBuilder(); $addInstanceContentBuilder->getTplId($tpl_id); $addInstanceContentBuilder->setTplParams($tpl_params); $addInstanceContentBuilder->setRecognitionType($recognition_type); $addInstanceContentBuilder->setRecognitionInfo($recognition_info); $request = new AopRequest (); $request->setBizContent($addInstanceContentBuilder->getBizContent()); $request->setApiMethodName("alipay.pass.instance.add"); return($this->execute($request, NULL, NULL)) ; } public function updateInstance(string $serial_number,string $channel_id,string $tpl_params,string $status,string $verify_code,string $verify_type) { //构造查询业务请求参数对象 $updateInstanceContentBuilder = new AlipayPassInstanceUpdateContentBuilder(); $updateInstanceContentBuilder->setSerialNumber($serial_number); $updateInstanceContentBuilder->setChannelId($channel_id); $updateInstanceContentBuilder->setTplParams($tpl_params); $updateInstanceContentBuilder->setStatus($status); $updateInstanceContentBuilder->setVerifyCode($verify_code); $updateInstanceContentBuilder->setVerifyType($verify_type); $request = new AopRequest (); $request->setBizContent($updateInstanceContentBuilder->getBizContent()); $request->setApiMethodName("alipay.pass.instance.update"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Marketing/Pass/ServiceProvider.php
src/Marketing/Pass/ServiceProvider.php
<?php namespace EasyAlipay\Marketing\Pass; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { /** * {@inheritdoc}. */ public function register(Container $app) { // var_dump($app); $app['pass'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Application.php
src/Payment/Application.php
<?php namespace EasyAlipay\Payment; use EasyAlipay\Kernel\ServiceContainer; /** * Class Application. * * @property \EasyAlipay\Payment\Cancel\Client $cancel * @property \EasyAlipay\Payment\Close\Client $close * @property \EasyAlipay\Payment\Create\Client $create * @property \EasyAlipay\Payment\Pay\Client $pay * @property \EasyAlipay\Payment\Query\Client $query * @property \EasyAlipay\Payment\Refund\Client $refund * */ class Application extends ServiceContainer { /** * @var array */ protected $providers = [ Cancel\ServiceProvider::class, Close\ServiceProvider::class, Create\ServiceProvider::class, Pay\ServiceProvider::class, Query\ServiceProvider::class, Refund\ServiceProvider::class, ]; }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Model/AlipayTradePayContentBuilder.php
src/Payment/Model/AlipayTradePayContentBuilder.php
<?php namespace EasyAlipay\Payment\Model; /* * * 功能:alipay.trade.pay(统一收单交易支付接口)接口业务参数封装 */ class AlipayTradePayContentBuilder { // 商户订单号. private $outTradeNo; // 支付场景 private $scene; // 支付授权码 private $authCode; // 订单标题,粗略描述用户的支付目的。 private $subject; // 订单总金额,整形,此处单位为元,精确到小数点后2位,不能超过1亿元 private $totalAmount; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getOutTradeNo() { return $this->outTradeNo; } public function setOutTradeNo($outTradeNo) { $this->outTradeNo = $outTradeNo; $this->bizContentarr['out_trade_no'] = $outTradeNo; } public function getScene() { return $this->scene; } public function setScene($scene) { $this->scene = $scene; $this->bizContentarr['scene'] = $scene; } public function getAuthCode() { return $this->authCode; } public function setAuthCode($authCode) { $this->authCode = $authCode; $this->bizContentarr['authCode'] = $authCode; } public function setSubject($subject) { $this->subject = $subject; $this->bizContentarr['subject'] = $subject; } public function getSubject() { return $this->subject; } public function setTotalAmount($totalAmount) { $this->totalAmount = $totalAmount; $this->bizContentarr['total_amount'] = $totalAmount; } public function getTotalAmount() { return $this->totalAmount; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Model/AlipayTradeRefundContentBuilder.php
src/Payment/Model/AlipayTradeRefundContentBuilder.php
<?php namespace EasyAlipay\Payment\Model; /* * * 功能:alipay.trade.refund(统一收单交易退款接口)接口业务参数封装 */ class AlipayTradeRefundContentBuilder { // 商户订单号. private $outTradeNo; // 支付宝交易号 private $tradeNo; // 退款的金额 private $refundAmount; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTradeNo() { return $this->tradeNo; } public function setTradeNo($tradeNo) { $this->tradeNo = $tradeNo; $this->bizContentarr['trade_no'] = $tradeNo; } public function getOutTradeNo() { return $this->outTradeNo; } public function setOutTradeNo($outTradeNo) { $this->outTradeNo = $outTradeNo; $this->bizContentarr['out_trade_no'] = $outTradeNo; } public function getRefundAmount() { return $this->refundAmount; } public function setRefundAmount($refundAmount) { $this->refundAmount = $refundAmount; $this->bizContentarr['refund_amount'] = $refundAmount; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Model/AlipayTradeCreateContentBuilder.php
src/Payment/Model/AlipayTradeCreateContentBuilder.php
<?php namespace EasyAlipay\Payment\Model; /* * * 功能:alipay.trade.create (统一收单交易关闭接口)业务参数封装 */ class AlipayTradeCreateContentBuilder { // 商户订单号. private $outTradeNo; // 订单标题,粗略描述用户的支付目的。 private $subject; // 订单总金额,整形,此处单位为元,精确到小数点后2位,不能超过1亿元 private $totalAmount; //买家的支付宝唯一用户号(2088开头的16位纯数字) private $buyerId; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTradeNo() { return $this->tradeNo; } public function setTradeNo($tradeNo) { $this->tradeNo = $tradeNo; $this->bizContentarr['trade_no'] = $tradeNo; } public function getOutTradeNo() { return $this->outTradeNo; } public function setOutTradeNo($outTradeNo) { $this->outTradeNo = $outTradeNo; $this->bizContentarr['out_trade_no'] = $outTradeNo; } public function setSubject($subject) { $this->subject = $subject; $this->bizContentarr['subject'] = $subject; } public function getSubject() { return $this->subject; } public function setTotalAmount($totalAmount) { $this->totalAmount = $totalAmount; $this->bizContentarr['total_amount'] = $totalAmount; } public function getTotalAmount() { return $this->totalAmount; } public function getBuyerId() { return $this->buyerId; } public function setBuyerId($buyerId) { $this->buyerId = $buyerId; $this->bizContentarr['buyer_id'] = $buyerId; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Model/AlipayTradeCancelContentBuilder.php
src/Payment/Model/AlipayTradeCancelContentBuilder.php
<?php namespace EasyAlipay\Payment\Model; /* * * 功能:alipay.trade.cancel (统一收单交易关闭接口)业务参数封装 */ class AlipayTradeCancelContentBuilder { // 商户订单号. private $outTradeNo; // 支付宝交易号 private $tradeNo; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTradeNo() { return $this->tradeNo; } public function setTradeNo($tradeNo) { $this->tradeNo = $tradeNo; $this->bizContentarr['trade_no'] = $tradeNo; } public function getOutTradeNo() { return $this->outTradeNo; } public function setOutTradeNo($outTradeNo) { $this->outTradeNo = $outTradeNo; $this->bizContentarr['out_trade_no'] = $outTradeNo; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Model/AlipayTradeQueryContentBuilder.php
src/Payment/Model/AlipayTradeQueryContentBuilder.php
<?php namespace EasyAlipay\Payment\Model; /* * * 功能:alipay.trade.query(统一收单线下交易查询)接口业务参数封装 */ class AlipayTradeQueryContentBuilder { // 商户订单号 private $outTradeNo; // 支付宝交易号 private $tradeNo; //银行间联模式下有用,其它场景请不要使用,双联通过该参数指定需要查询的交易所属收单机构的pid; private $orgPid; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTradeNo() { return $this->tradeNo; } public function setTradeNo($tradeNo) { $this->tradeNo = $tradeNo; $this->bizContentarr['trade_no'] = $tradeNo; } public function getOutTradeNo() { return $this->outTradeNo; } public function setOutTradeNo($outTradeNo) { $this->outTradeNo = $outTradeNo; $this->bizContentarr['out_trade_no'] = $outTradeNo; } public function getOrgPid() { return $this->orgPid; } public function setOrgPid($orgPid) { $this->orgPid = $orgPid; $this->bizContentarr['org_pid'] = $orgPid; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Model/AlipayTradeCloseContentBuilder.php
src/Payment/Model/AlipayTradeCloseContentBuilder.php
<?php namespace EasyAlipay\Payment\Model; /* * * 功能:alipay.trade.close (统一收单交易关闭接口)业务参数封装 */ class AlipayTradeCloseContentBuilder { // 商户订单号. private $outTradeNo; // 支付宝交易号 private $tradeNo; //卖家端自定义的的操作员 ID private $operatorId; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getTradeNo() { return $this->tradeNo; } public function setTradeNo($tradeNo) { $this->tradeNo = $tradeNo; $this->bizContentarr['trade_no'] = $tradeNo; } public function getOutTradeNo() { return $this->outTradeNo; } public function setOutTradeNo($outTradeNo) { $this->outTradeNo = $outTradeNo; $this->bizContentarr['out_trade_no'] = $outTradeNo; } public function getOperatorId() { return $this->operatorId; } public function setOperatorId($operatorId) { $this->operatorId = $operatorId; $this->bizContentarr['operator_id'] = $operatorId; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Cancel/Client.php
src/Payment/Cancel/Client.php
<?php namespace EasyAlipay\Payment\Cancel; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Payment\Model\AlipayTradeCancelContentBuilder; class Client extends AopClient { public function cancel(string $out_trade_no) { //构造查询业务请求参数对象 $cancelContentBuilder = new AlipayTradeCancelContentBuilder(); $cancelContentBuilder->setOutTradeNo($out_trade_no); $request = new AopRequest (); $request->setBizContent($cancelContentBuilder->getBizContent()); $request->setApiMethodName("alipay.trade.cancel"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Cancel/ServiceProvider.php
src/Payment/Cancel/ServiceProvider.php
<?php namespace EasyAlipay\Payment\Cancel; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['cancel'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Refund/Client.php
src/Payment/Refund/Client.php
<?php namespace EasyAlipay\Payment\Refund; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Payment\Model\AlipayTradeRefundContentBuilder; class Client extends AopClient { public function refund(string $out_trade_no,string $refund_amount) { //构造查询业务请求参数对象 $refundContentBuilder = new AlipayTradeRefundContentBuilder(); $refundContentBuilder->setOutTradeNo($out_trade_no); $refundContentBuilder->setRefundAmount($refund_amount); $request = new AopRequest (); $request->setBizContent($refundContentBuilder->getBizContent()); $request->setApiMethodName("alipay.trade.refund"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Refund/ServiceProvider.php
src/Payment/Refund/ServiceProvider.php
<?php namespace EasyAlipay\Payment\Refund; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['refund'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Query/Client.php
src/Payment/Query/Client.php
<?php namespace EasyAlipay\Payment\Query; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Payment\Model\AlipayTradeQueryContentBuilder; class Client extends AopClient { public function query(string $out_trade_no) { //构造查询业务请求参数对象 $queryContentBuilder = new AlipayTradeQueryContentBuilder(); $queryContentBuilder->setOutTradeNo($out_trade_no); $request = new AopRequest (); $request->setBizContent($queryContentBuilder->getBizContent()); $request->setApiMethodName("alipay.trade.query"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Query/ServiceProvider.php
src/Payment/Query/ServiceProvider.php
<?php namespace EasyAlipay\Payment\Query; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['query'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Close/Client.php
src/Payment/Close/Client.php
<?php namespace EasyAlipay\Payment\Close; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Payment\Model\AlipayTradeCloseContentBuilder; class Client extends AopClient { public function close(string $out_trade_no) { //构造查询业务请求参数对象 $closeContentBuilder = new AlipayTradeCloseContentBuilder(); $closeContentBuilder->setOutTradeNo($out_trade_no); $request = new AopRequest (); $request->setBizContent($closeContentBuilder->getBizContent()); $request->setApiMethodName("alipay.trade.close"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Close/ServiceProvider.php
src/Payment/Close/ServiceProvider.php
<?php namespace EasyAlipay\Payment\Close; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['close'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Pay/Client.php
src/Payment/Pay/Client.php
<?php namespace EasyAlipay\Payment\Pay; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Payment\Model\AlipayTradePayContentBuilder; class Client extends AopClient { public function pay(string $subject,string $out_trade_no,string $total_amount,string $auth_code) { //构造查询业务请求参数对象 $payContentBuilder = new AlipayTradePayContentBuilder(); $payContentBuilder->setSubject($subject); $payContentBuilder->setOutTradeNo($out_trade_no); $payContentBuilder->setTotalAmount($total_amount); $payContentBuilder->setScene("bar_code"); $payContentBuilder->setAuthCode($auth_code); $request = new AopRequest (); $request->setBizContent($payContentBuilder->getBizContent()); $request->setApiMethodName("alipay.trade.pay"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Pay/ServiceProvider.php
src/Payment/Pay/ServiceProvider.php
<?php namespace EasyAlipay\Payment\Pay; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['pay'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Create/Client.php
src/Payment/Create/Client.php
<?php namespace EasyAlipay\Payment\Create; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Payment\Model\AlipayTradeCreateContentBuilder; class Client extends AopClient { public function create(string $subject,string $out_trade_no,string $total_amount,string $buyer_id) { //构造查询业务请求参数对象 $createContentBuilder = new AlipayTradeCreateContentBuilder(); $createContentBuilder->setSubject($subject); $createContentBuilder->setOutTradeNo($out_trade_no); $createContentBuilder->setTotalAmount($total_amount); $createContentBuilder->setBuyerId($buyer_id); $request = new AopRequest (); $request->setBizContent($createContentBuilder->getBizContent()); $request->setApiMethodName("alipay.trade.create"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Payment/Create/ServiceProvider.php
src/Payment/Create/ServiceProvider.php
<?php namespace EasyAlipay\Payment\Create; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['create'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Application.php
src/Mini/Application.php
<?php namespace EasyAlipay\Mini; use EasyAlipay\Kernel\ServiceContainer; /** * Class Application. * * @property \EasyAlipay\Mini\Identification\Client $identification * @property \EasyAlipay\Mini\Qrcode\Client $qrcode * @property \EasyAlipay\Mini\TemplateMessage\Client $templateMessage * @property \EasyAlipay\Mini\Risk\Client $risk * */ class Application extends ServiceContainer { /** * @var array */ protected $providers = [ Identification\ServiceProvider::class, Qrcode\ServiceProvider::class, TemplateMessage\ServiceProvider::class, Risk\ServiceProvider::class, ]; }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Model/AlipaySecurityRiskContentDetectContentBuilder.php
src/Mini/Model/AlipaySecurityRiskContentDetectContentBuilder.php
<?php namespace EasyAlipay\Mini\Model; /* * * 功能:alipay.security.risk.content.detect(小程序内容风险检测服务) 业务参数封装 */ class AlipaySecurityRiskContentDetectContentBuilder { // 需要识别的文本,不要包含特殊字符以及双引号等可能引起json格式化错误问题的字符. private $content; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getContent() { return $this->content; } public function setContent($content) { $this->content = $content; $this->bizContentarr['content'] = $content; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Model/AlipayOpenAppMiniTemplatemessageSendContentBuilder.php
src/Mini/Model/AlipayOpenAppMiniTemplatemessageSendContentBuilder.php
<?php namespace EasyAlipay\Mini\Model; /* * * 功能:alipay.open.app.mini.templatemessage.send(小程序发送模板消息) 业务参数封装 * 前置条件:https://docs.alipay.com/mini/introduce/message */ class AlipayOpenAppMiniTemplatemessageSendContentBuilder { // 发送消息的用户userid,例如:2088102122458832 private $toUserId; // 用户发生的交易行为的交易号,或者用户在小程序产生表单提交的表单号,用于信息发送的校验,例如:2017010100000000580012345678 private $formId; // 用户申请的模板id号,固定的模板id会发送固定的消息,例如:MDI4YzIxMDE2M2I5YTQzYjUxNWE4MjA4NmU1MTIyYmM= private $userTemplateId; // 小程序的跳转页面,用于消息中心用户点击之后详细跳转的小程序页面,例如:page/component/index private $page; // 开发者需要发送模板消息中的自定义部分来替换模板的占位符,例如:{"keyword1": {"value" : "12:00"},"keyword2": {"value" : "20180808"},"keyword3": {"value" : "支付宝"}} private $data; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getToUserId() { return $this->toUserId; } public function setToUserId($toUserId) { $this->toUserId = $toUserId; $this->bizContentarr['to_user_id'] = $toUserId; } public function getFormId() { return $this->formId; } public function setFormId($formId) { $this->formId = $formId; $this->bizContentarr['form_id'] = $formId; } public function getUserTemplateId() { return $this->userTemplateId; } public function setUserTemplateId($userTemplateId) { $this->userTemplateId = $userTemplateId; $this->bizContentarr['user_template_id'] = $userTemplateId; } public function getPage() { return $this->page; } public function setPage($page) { $this->page = $page; $this->bizContentarr['page'] = $page; } public function getData() { return $this->data; } public function setData($data) { $this->data = $data; $this->bizContentarr['data'] = $data; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Model/ZolozIdentificationCustomerCertifyzhubQueryContentBuilder.php
src/Mini/Model/ZolozIdentificationCustomerCertifyzhubQueryContentBuilder.php
<?php namespace EasyAlipay\Mini\Model; /* * * 功能:zoloz.identification.customer.certifyzhub.query (人脸结果查询接口)业务参数封装 * 前置条件:https://docs.alipay.com/mini/introduce/alipay-face-verify,需要先调用接口 my.ap.faceVerify,传入入参 bizId 和 bizType 唤起刷脸认证,认证结束后,通过回调函数得到认证结果。确保业务参数 biz_id 和 faceVerify 中的入参 bizId 一致,否则会导致查询失败。 */ class ZolozIdentificationCustomerCertifyzhubQueryContentBuilder { // 业务单据号,用于核对和排查.需要先调用接口 my.ap.faceVerify,传入入参 bizId 和 bizType 唤起刷脸认证,认证结束后,通过回调函数得到认证结果。确保业务参数 biz_id 和 faceVerify 中的入参 bizId 一致,否则会导致查询失败。 private $bizId; // 刷脸认证的唯一标识,用于查询认证结果 private $zimId; // 0:匿名注册 1:匿名认证 2:实名认证 private $faceType; // 是否需要返回人脸图片 private $needImg; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getBizId() { return $this->bizId; } public function setBizId($bizId) { $this->bizId = $bizId; $this->bizContentarr['biz_id'] = $bizId; } public function getZimId() { return $this->zimId; } public function setZimId($zimId) { $this->zimId = $zimId; $this->bizContentarr['zim_id'] = $zimId; } public function getFaceType() { return $this->faceType; } public function setFaceType($faceType) { $this->faceType = $faceType; $this->bizContentarr['face_type'] = $faceType; } public function getNeedImg() { return $this->needImg; } public function setNeedImg($needImg) { $this->needImg = $needImg; $this->bizContentarr['need_img'] = $needImg; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Model/AlipayOpenAppQrcodeCreateContentBuilder.php
src/Mini/Model/AlipayOpenAppQrcodeCreateContentBuilder.php
<?php namespace EasyAlipay\Mini\Model; /* * * 功能:alipay.open.app.qrcode.create (小程序生成推广二维码接口)业务参数封装 */ class AlipayOpenAppQrcodeCreateContentBuilder { // 小程序中能访问到的页面路径,例如:page/component/component-pages/view/view private $urlParam; // 小程序的启动参数,打开小程序的query ,在小程序 onLaunch的方法中获取,例如:x=1 private $queryParam; // 对应的二维码描述 private $describe; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getUrlParam() { return $this->urlParam; } public function setUrlParam($urlParam) { $this->urlParam = $urlParam; $this->bizContentarr['url_param'] = $urlParam; } public function getQueryParam() { return $this->queryParam; } public function setQueryParam($queryParam) { $this->queryParam = $queryParam; $this->bizContentarr['query_param'] = $queryParam; } public function getDescribe() { return $this->describe; } public function setDescribe($describe) { $this->describe = $describe; $this->bizContentarr['describe'] = $describe; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Model/ZolozIdentificationUserWebQueryContentBuilder.php
src/Mini/Model/ZolozIdentificationUserWebQueryContentBuilder.php
<?php namespace EasyAlipay\Mini\Model; /* * * 功能:zoloz.identification.user.web.query(人脸采集结果查询接口)接口业务参数封装 * 前置条件:https://docs.alipay.com/mini/introduce/facecapture,调用JSAPI(faceVerify)唤起人脸采集,整个采集过程完全由人脸内部实现,采集完成后,通过回调函数返回采集结果。调用查询接口(zoloz.identification.user.web.query)获取可信的采集结果,如果采集成功,可通过此接口获取采集的人脸照片。 */ class ZolozIdentificationUserWebQueryContentBuilder { // 商户请求的唯一标识,须与初始化传入的bizId保持一致。 private $bizId; // 刷脸认证的唯一标识,用于查询认证结果 private $zimId; // 扩展参数 private $externParam; private $bizContentarr = array(); private $bizContent = NULL; public function getBizContent() { if(!empty($this->bizContentarr)){ $this->bizContent = json_encode($this->bizContentarr,JSON_UNESCAPED_UNICODE); } return $this->bizContent; } public function getBizId() { return $this->bizId; } public function setBizId($bizId) { $this->bizId = $bizId; $this->bizContentarr['biz_id'] = $bizId; } public function getZimId() { return $this->zimId; } public function setZimId($zimId) { $this->zimId = $zimId; $this->bizContentarr['zim_id'] = $zimId; } public function getExternParam() { return $this->externParam; } public function setExternParam($externParam) { $this->externParam = $externParam; $this->bizContentarr['extern_param'] = $externParam; } } ?>
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Risk/Client.php
src/Mini/Risk/Client.php
<?php namespace EasyAlipay\Mini\Risk; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Mini\Model\AlipaySecurityRiskContentDetectContentBuilder; class Client extends AopClient { public function detectContent(string $content) { //构造查询业务请求参数对象 $riskContentBuilder = new AlipaySecurityRiskContentDetectContentBuilder(); $riskContentBuilder->setContent($content); $request = new AopRequest (); $request->setBizContent($riskContentBuilder->getBizContent()); $request->setApiMethodName("alipay.security.risk.content.detect"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Risk/ServiceProvider.php
src/Mini/Risk/ServiceProvider.php
<?php namespace EasyAlipay\Mini\Risk; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { /** * {@inheritdoc}. */ public function register(Container $app) { // var_dump($app); $app['risk'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Qrcode/Client.php
src/Mini/Qrcode/Client.php
<?php namespace EasyAlipay\Mini\Qrcode; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Mini\Model\AlipayOpenAppQrcodeCreateContentBuilder; class Client extends AopClient { public function create(string $url_param,string $query_param,string $describe) { //构造查询业务请求参数对象 $qrcodeContentBuilder = new AlipayOpenAppQrcodeCreateContentBuilder(); $qrcodeContentBuilder->setUrlParam($url_param); $qrcodeContentBuilder->setQueryParam($query_param); $qrcodeContentBuilder->setDescribe($describe); $request = new AopRequest (); $request->setBizContent($qrcodeContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.app.qrcode.create"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Qrcode/ServiceProvider.php
src/Mini/Qrcode/ServiceProvider.php
<?php namespace EasyAlipay\Mini\Qrcode; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['qrcode'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/TemplateMessage/Client.php
src/Mini/TemplateMessage/Client.php
<?php namespace EasyAlipay\Mini\TemplateMessage; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Mini\Model\AlipayOpenAppMiniTemplatemessageSendContentBuilder; class Client extends AopClient { public function send(string $to_user_id,string $form_id,string $user_template_id,string $page,string $data) { //构造查询业务请求参数对象 $sendContentBuilder = new AlipayOpenAppMiniTemplatemessageSendContentBuilder(); $sendContentBuilder->setToUserId($to_user_id); $sendContentBuilder->setFormId($form_id); $sendContentBuilder->setUserTemplateId($user_template_id); $sendContentBuilder->setPage($page); $sendContentBuilder->setData($data); $request = new AopRequest (); $request->setBizContent($sendContentBuilder->getBizContent()); $request->setApiMethodName("alipay.open.app.mini.templatemessage.send"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/TemplateMessage/ServiceProvider.php
src/Mini/TemplateMessage/ServiceProvider.php
<?php namespace EasyAlipay\Mini\TemplateMessage; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['templateMessage'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Identification/Client.php
src/Mini/Identification/Client.php
<?php namespace EasyAlipay\Mini\Identification; use EasyAlipay\Kernel\AopClient; use EasyAlipay\Kernel\AopRequest; use EasyAlipay\Mini\Model\ZolozIdentificationCustomerCertifyzhubQueryContentBuilder; use EasyAlipay\Mini\Model\ZolozIdentificationUserWebQueryContentBuilder; class Client extends AopClient { public function queryCertifyzhub(string $biz_id,string $zim_id) { //构造查询业务请求参数对象 $zhubQueryContentBuilder = new ZolozIdentificationCustomerCertifyzhubQueryContentBuilder(); $zhubQueryContentBuilder->setBizId($biz_id); $zhubQueryContentBuilder->setZimId($zim_id); $zhubQueryContentBuilder->setFaceType(2); $request = new AopRequest (); $request->setBizContent($zhubQueryContentBuilder->getBizContent()); $request->setApiMethodName("zoloz.identification.customer.certifyzhub.query"); return($this->execute($request, NULL, NULL)) ; } public function queryUserWeb(string $biz_id,string $zim_id,string $extern_param) { //构造查询业务请求参数对象 $userWebQueryContentBuilder = new ZolozIdentificationUserWebQueryContentBuilder(); $userWebQueryContentBuilder->setBizId($biz_id); $userWebQueryContentBuilder->setZimId($zim_id); $userWebQueryContentBuilder->setExternParam($extern_param); $request = new AopRequest (); $request->setBizContent($userWebQueryContentBuilder->getBizContent()); $request->setApiMethodName("zoloz.identification.user.web.query"); return($this->execute($request, NULL, NULL)) ; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/src/Mini/Identification/ServiceProvider.php
src/Mini/Identification/ServiceProvider.php
<?php namespace EasyAlipay\Mini\Identification; use Pimple\Container; use Pimple\ServiceProviderInterface; class ServiceProvider implements ServiceProviderInterface { public function register(Container $app) { $app['identification'] = function ($app) { return new Client($app); }; } }
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
shulidata/easyalipay
https://github.com/shulidata/easyalipay/blob/4013a1e39556a4b321bd510f3ca05c11cf16c240/tests/test.php
tests/test.php
<?php require __DIR__.'/../vendor/autoload.php'; use EasyAlipay\Factory; $options = [ 'app_id' => '2016051900098985', 'gateway_url' => "https://openapi.alipaydev.com/gateway.do",//示例中使用的是沙箱环境网关,线上gateway_url:https://openapi.alipay.com/gateway.do 'sign_type' => "RSA", 'charset' => "UTF-8", 'alipay_public_key' => 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDIgHnOn7LLILlKETd6BFRJ0GqgS2Y3mn1wMQmyh9zEyWlz5p1zrahRahbXAfCfSqshSNfqOmAQzSHRVjCqjsAw1jyqrXaPdKBmr90DIpIxmIyKXv4GGAkPyJ/6FTFY99uhpiq0qadD/uSzQsefWo0aTvP/65zi3eof7TcZ32oWpwIDAQAB', 'merchant_private_key' => 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJlJ7tgZ4vI2Nnxt7DzznbhVwGN8INQ1s/ZnXYgtRMmvbNKLTHZ1SbRmiAKixn3TDbzkHMvo0jY7ldb7puqUJUKZuKfVwaRcAYgI6NamflqtTDWhSq+hPZ5ZrB36lx7N7AxlMD038WvJC5pHbld06DDxhlUslS3pJCGrB9P6HO0RAgMBAAECgYArrFTQXQ+70pZTfT4BX6dgDY5yybrQuzw6x9huI/elPsXSdr2iQmhtbYjyt022K5uOZa+OqRa7PN7EEY7M5sh2cFRX5P77o2vN61Gwklc11iaJIpPgUOZUmAG8jHnj3lf40+YtMwdPxQfbiZ36UOebQYPc8iuJczUNoVtSPP3IwQJBAMZzCSV7pjTQ4mp2MNT/h3/5ZhaQnqlO4wm0etekKDDTrpvUlSN8MjRjhyJhRvulKd0zUdfrjASEUjZhsZydEAMCQQDFviiKquR0TgYK0eircDwR89XHUBKoblPLYi/GSdPXSL92AzyvDIyNF/GPwHOkc1c+BA/4ocuW/T+u4KfYWBRbAkEAvV/Rfp98gDJFnmqjNt+SIqGQtj/T6KWLKxu7jkTsxYt7uOEoYPCHyE6iCkDiSAnY5Wmv1GjG+Rh8i8C2iUmomQJBAIaeVmtQvAaRt3tWO9e6qKpwHXF7Cbiwo0sqpOuRBy7gz7c/rOhe2rCTRFhg5FloTFRj35ucSkWYUupy9tFJ5VECQDyK++bn0ZpJG/HRNJHvuKOSUM8U6LSvQrTGpyvKlj5wLcOniDAYEcCzkapY/wHAUMshD0eoFY2X3F/3PcuIgW4=', // ... ]; //本测试用例提供的是沙箱环境的配置信息,线上调用请更改为自己应用对应的信息 //app_id,alipay_public_key(支付宝公钥),merchant_private_key(应用私钥)为必填项 //gateway_url不设置就默认线上网关 //sign_type 不设置就默认RSA2(目前线上环境支持RSA) //charset 不设置就默认UTF-8 //接口测试用例 $app = Factory::payment($options); var_dump($app['query']->query("1561946980099_demo_pay"));
php
MIT
4013a1e39556a4b321bd510f3ca05c11cf16c240
2026-01-05T05:19:35.786882Z
false
AdrianSkierniewski/eloquent-tree
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Observer.php
src/Gzero/EloquentTree/Model/Observer.php
<?php namespace Gzero\EloquentTree\Model; use DB; /** * Class Observer * * @author Adrian Skierniewski <adrian.skierniewski@gmail.com> * @package Gzero\EloquentTree\Model */ class Observer { /** * When saving node we must set path and level * * @param Tree $model */ public function saving(Tree $model) { if (!$model->exists and !in_array('path', array_keys($model->attributesToArray()), TRUE)) { $model->{$model->getTreeColumn('path')} = ''; $model->{$model->getTreeColumn('parent')} = NULL; $model->{$model->getTreeColumn('level')} = 0; } } /** * After mode was saved we're building node path * * @param Tree $model */ public function saved(Tree $model) { if ($model->{$model->getTreeColumn('path')} === '') { // If we just save() new node $model->{$model->getTreeColumn('path')} = $model->getKey() . '/'; DB::connection($model->getConnectionName())->table($model->getTable()) ->where($model->getKeyName(), '=', $model->getKey()) ->update( array( $model->getTreeColumn('path') => $model->{$model->getTreeColumn('path')} ) ); } } }
php
MIT
de4065b9ef3977702d62227bf9a5afccb710fa82
2026-01-05T05:19:45.893021Z
false
AdrianSkierniewski/eloquent-tree
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php
src/Gzero/EloquentTree/Model/Tree.php
<?php namespace Gzero\EloquentTree\Model; use DB; use Gzero\EloquentTree\Model\Exception\MissingParentException; use Gzero\EloquentTree\Model\Exception\SelfConnectionException; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model as Eloquent; /** * Class Tree * * This class represents abstract tree model for inheritance * * @author Adrian Skierniewski <adrian.skierniewski@gmail.com> * @package Gzero\EloquentTree\Model */ abstract class Tree extends Eloquent { /** * Database tree fields * * @var array */ protected static $treeColumns = [ 'path' => 'path', 'parent' => 'parent_id', 'level' => 'level' ]; /** * @inheritdoc */ public function __construct(array $attributes = []) { parent::__construct($attributes); $this->addTreeEvents(); // Adding tree events } /** * Set node as root node * * @return $this */ public function setAsRoot() { $this->handleNewNodes(); if (!$this->isRoot()) { // Only if it is not already root if ($this->fireModelEvent('updatingParent') === false) { return $this; } $oldDescendants = $this->getOldDescendants(); $this->{$this->getTreeColumn('path')} = $this->getKey() . '/'; $this->{$this->getTreeColumn('parent')} = null; $this->setRelation('parent', null); $this->{$this->getTreeColumn('level')} = 0; $this->save(); $this->fireModelEvent('updatedParent', false); $this->updateDescendants($this, $oldDescendants); } return $this; } /** * Set node as child of $parent node * * @param Tree $parent * * @return $this */ public function setChildOf(Tree $parent) { $this->handleNewNodes(); if ($this->validateSetChildOf($parent)) { if ($this->fireModelEvent('updatingParent') === false) { return $this; } $oldDescendants = $this->getOldDescendants(); $this->{$this->getTreeColumn('path')} = $this->generateNewPath($parent); $this->{$this->getTreeColumn('parent')} = $parent->getKey(); $this->{$this->getTreeColumn('level')} = $parent->{$this->getTreeColumn('level')} + 1; $this->save(); $this->fireModelEvent('updatedParent', false); $this->updateDescendants($this, $oldDescendants); } return $this; } /** * Validate if parent change and prevent self connection * * @param Tree $parent New parent node * * @return bool * @throws Exception\SelfConnectionException */ public function validateSetChildOf(Tree $parent) { if ($parent->getKey() == $this->getKey()) { throw new SelfConnectionException(); } if ($parent->{$this->getTreeColumn('path')} != $this->removeLastNodeFromPath()) { // Only if new parent return true; } return false; } /** * Set node as sibling of $sibling node * * @param Tree $sibling New sibling node * * @return $this */ public function setSiblingOf(Tree $sibling) { $this->handleNewNodes(); if ($this->validateSetSiblingOf($sibling)) { if ($this->fireModelEvent('updatingParent') === false) { return $this; } $oldDescendants = $this->getOldDescendants(); $this->{$this->getTreeColumn('path')} = $sibling->removeLastNodeFromPath() . $this->getKey() . '/'; $this->{$this->getTreeColumn('parent')} = $sibling->{$this->getTreeColumn('parent')}; $this->{$this->getTreeColumn('level')} = $sibling->{$this->getTreeColumn('level')}; $this->save(); $this->fireModelEvent('updatedParent', false); $this->updateDescendants($this, $oldDescendants); } return $this; } /** * Validate if parent change and prevent self connection * * @param Tree $sibling New sibling node * * @return bool */ public function validateSetSiblingOf(Tree $sibling) { if ($sibling->removeLastNodeFromPath() != $this->removeLastNodeFromPath()) { // Only if new parent and != self return true; } return false; } /** * Check if node is root * This function check foreign key field * * @return bool */ public function isRoot() { return (empty($this->{$this->getTreeColumn('parent')})) ? true : false; } /** * Check if node is sibling for passed node * * @param Tree $node * * @return bool */ public function isSibling(Tree $node) { return $this->{$this->getTreeColumn('parent')} === $node->{$this->getTreeColumn('parent')}; } /** * Get parent to specific node (if exist) * * @return static */ public function parent() { return $this->belongsTo(get_class($this), $this->getTreeColumn('parent'), $this->getKeyName()); } /** * Get children to specific node (if exist) * * @return static */ public function children() { return $this->hasMany(get_class($this), $this->getTreeColumn('parent'), $this->getKeyName()); } /** * Find all descendants for specific node with this node as root * * @return \Illuminate\Database\Eloquent\Builder */ public function findDescendants() { return static::where($this->getTreeColumn('path'), 'LIKE', $this->{$this->getTreeColumn('path')} . '%') ->orderBy($this->getTreeColumn('level'), 'ASC'); } /** * Find all ancestors for specific node with this node as leaf * * @return \Illuminate\Database\Eloquent\Builder */ public function findAncestors() { return static::whereIn($this->getKeyName(), $this->extractPath()) ->orderBy($this->getTreeColumn('level'), 'ASC'); } /** * Find root for this node * * @return $this */ public function findRoot() { if ($this->isRoot()) { return $this; } else { $extractedPath = $this->extractPath(); $root_id = array_shift($extractedPath); return static::where($this->getKeyName(), '=', $root_id)->first(); } } /** * Rebuilds trees from passed nodes * * @param Collection $nodes Nodes from which we are build tree * @param bool $strict If we want to make sure that there are no orphan nodes * * @return static Root node * @throws MissingParentException */ public function buildTree(Collection $nodes, $strict = true) { $refs = []; // Reference table to store records in the construction of the tree $count = 0; $roots = new Collection(); foreach ($nodes as &$node) { /* @var Tree $node */ $node->initChildrenRelation(); // We need to init relation to avoid LAZY LOADING in future $refs[$node->getKey()] = &$node; // Adding to ref table (we identify after the id) if ($count === 0) { $roots->add($node); $count++; } else { if ($this->siblingOfRoot($node, $roots)) { // We use this condition as a factor in building subtrees $roots->add($node); } else { // This is not a root, so add them to the parent $index = $node->{$this->getTreeColumn('parent')}; if (!empty($refs[$index])) { // We should already have parent for our node added to refs array $refs[$index]->addChildToCollection($node); } else { if ($strict) { // We don't want to ignore orphan nodes throw new MissingParentException(); } } } } } if (!empty($roots)) { if (count($roots) > 1) { return $roots; } else { return $roots->first(); } } else { return false; } } /** * Displays a tree as html * Rendering function accept {sub-tree} tag, represents next tree level * * EXAMPLE: * $root->render( * 'ul', * function ($node) { * return '<li>' . $node->title . '{sub-tree}</li>'; * }, * TRUE * ); * * @param string $tag HTML tag for level section * @param callable $render Rendering function * @param bool $displayRoot Is the root will be displayed * * @return string */ public function render($tag, Callable $render, $displayRoot = true) { $out = ''; if ($displayRoot) { $out .= '<' . $tag . ' class="tree tree-level-' . $this->{$this->getTreeColumn('level')} . '">'; $root = $render($this); $nextLevel = $this->renderRecursiveTree($this, $tag, $render); $out .= preg_replace('/{sub-tree}/', $nextLevel, $root); $out .= '</' . $tag . '>'; } else { $out = $this->renderRecursiveTree($this, $tag, $render); } return $out; } /** * Determine if we've already loaded the children * Used to prevent lazy loading on children * * @return bool */ public function isChildrenLoaded() { return isset($this->relations['children']); } //--------------------------------------------------------------------------------------------------------------- // START STATIC //--------------------------------------------------------------------------------------------------------------- /** * Adds observer inheritance */ protected static function boot() { parent::boot(); static::observe(new Observer()); } /** * Gets all root nodes * * @return \Illuminate\Database\Eloquent\Builder */ public static function getRoots() { return static::whereNull(static::getTreeColumn('parent')); } /** * Gets all leaf nodes * * @return \Illuminate\Database\Eloquent\Builder */ public static function getLeaves() { $parents = static::select('parent_id')->whereNotNull('parent_id')->distinct()->get()->pluck('parent_id')->all(); return static::wherenotin('id',$parents); } /** * @param null $name * * @throws \Exception */ public static function getTreeColumn($name = null) { if (empty($name)) { return static::$treeColumns; } elseif (!empty(static::$treeColumns[$name])) { return static::$treeColumns[$name]; } throw new \Exception('Tree column: ' . $name . ' undefined'); } /** * Map array to tree structure in database * You must set $fillable attribute to use this function * * Example array: * array( * 'title' => 'root', * 'children' => array( * array('title' => 'node1'), * array('title' => 'node2') * ) * ); * * @param array $map Nodes recursive array */ public static function mapArray(Array $map) { foreach ($map as $item) { $root = new static($item); $root->setAsRoot(); if (isset($item['children'])) { static::mapDescendantsArray($root, $item['children']); } } } /** * Map array as descendants nodes in database to specific parent node * You must set $fillable attribute to use this function * * @param Tree $parent Parent node * @param array $map Nodes recursive array */ public static function mapDescendantsArray(Tree $parent, Array $map) { foreach ($map as $item) { $node = new static($item); $node->setChildOf($parent); if (isset($item['children'])) { static::mapDescendantsArray($node, $item['children']); } } } //--------------------------------------------------------------------------------------------------------------- // END STATIC //--------------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------------- // START PROTECTED/PRIVATE //--------------------------------------------------------------------------------------------------------------- /** * Creating node if not exist */ protected function handleNewNodes() { if (!$this->exists) { $this->save(); } } /** * Adds tree specific events * * @return array */ protected function addTreeEvents() { $this->observables = array_merge( [ 'updatedParent', 'updatingParent', 'updatedDescendants' ], $this->observables ); } /** * Extract path to array * * @return array */ protected function extractPath() { $path = explode('/', $this->{$this->getTreeColumn('path')}); array_pop($path); // Remove last empty element return $path; } /** * Removing last node id from path and returns it * * @return mixed Node path */ protected function removeLastNodeFromPath() { return preg_replace('/\d\/$/', '', $this->{$this->getTreeColumn('path')}); } /** * Generating new path based on parent path * * @param Tree $parent Parent node * * @return string New path */ protected function generateNewPath(Tree $parent) { return $parent->{$this->getTreeColumn('path')} . $this->getKey() . '/'; } /** * Adds children for this node while building the tree structure in PHP * * @param Tree $child Child node */ protected function addChildToCollection(&$child) { $this->setRelation('children', $this->getRelation('children')->add($child)); } /** * Gets old descendants before modify parent * * @return Collection|static[] */ protected function getOldDescendants() { $collection = $this->findDescendants()->get(); $collection->shift(); // Removing current node from update return $collection; } /** * Recursive render descendants * * @param $node * @param $tag * @param callable $render * * @return string */ protected function renderRecursiveTree($node, $tag, Callable $render) { $out = ''; $out .= '<' . $tag . ' class="tree tree-level-' . ($node->{$node->getTreeColumn('level')} + 1) . '">'; foreach ($node->children as $child) { if (!empty($child->children)) { $level = $render($child); $nextLevel = $this->renderRecursiveTree($child, $tag, $render); $out .= preg_replace('/{sub-tree}/', $nextLevel, $level); } else { $out .= preg_replace('/{sub-tree}/', '', $render($child)); } } return $out . '</' . $tag . '>'; } /** * Updating descendants nodes * * @param Tree $node Updated node * @param Collection $oldDescendants Old descendants collection (just before modify parent) */ protected function updateDescendants(Tree $node, $oldDescendants) { $refs = []; $refs[$node->getKey()] = &$node; // Updated node foreach ($oldDescendants as &$child) { $refs[$child->getKey()] = $child; $parent_id = $child->{$this->getTreeColumn('parent')}; if (!empty($refs[$parent_id])) { if ($refs[$parent_id]->path != $refs[$child->getKey()]->removeLastNodeFromPath()) { $refs[$child->getKey()]->level = $refs[$parent_id]->level + 1; // New level $refs[$child->getKey()]->path = $refs[$parent_id]->path . $child->getKey() . '/'; // New path DB::table($this->getTable()) ->where($child->getKeyName(), '=', $child->getKey()) ->update( [ $this->getTreeColumn('level') => $refs[$child->getKey()]->level, $this->getTreeColumn('path') => $refs[$child->getKey()]->path ] ); } } } $this->fireModelEvent('updatedDescendants', false); } /** * Check if node is sibling for roots in collection * * @param Tree $node Tree node * @param Collection $roots Collection of roots * * @return bool */ private function siblingOfRoot(Tree $node, Collection $roots) { return (bool) $roots->filter( function ($item) use ($node) { return $node->isSibling($item); } )->first(); } /** * Init children relation to avoid empty LAZY LOADING */ protected function initChildrenRelation() { $relations = $this->getRelations(); if (empty($relations['children'])) { $this->setRelation('children', new Collection()); } } //--------------------------------------------------------------------------------------------------------------- // END PROTECTED/PRIVATE //--------------------------------------------------------------------------------------------------------------- }
php
MIT
de4065b9ef3977702d62227bf9a5afccb710fa82
2026-01-05T05:19:45.893021Z
false
AdrianSkierniewski/eloquent-tree
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Exception/MissingParentException.php
src/Gzero/EloquentTree/Model/Exception/MissingParentException.php
<?php namespace Gzero\EloquentTree\Model\Exception; class MissingParentException extends \Exception { }
php
MIT
de4065b9ef3977702d62227bf9a5afccb710fa82
2026-01-05T05:19:45.893021Z
false
AdrianSkierniewski/eloquent-tree
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Exception/SelfConnectionException.php
src/Gzero/EloquentTree/Model/Exception/SelfConnectionException.php
<?php namespace Gzero\EloquentTree\Model\Exception; class SelfConnectionException extends \Exception { }
php
MIT
de4065b9ef3977702d62227bf9a5afccb710fa82
2026-01-05T05:19:45.893021Z
false
AdrianSkierniewski/eloquent-tree
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/tests/Test.php
tests/Test.php
<?php spl_autoload_register( // Autoload because we're using \Eloquent alias provided by Orchestra function ($class) { require_once 'Model/Tree.php'; } ); class Test extends Orchestra\Testbench\TestCase { /** * Default preparation for each test */ public function setUp() { parent::setUp(); $this->loadMigrationsFrom( [ '--database' => 'testbench', '--realpath' => realpath(__DIR__ . '/migrations'), ] ); } public function tearDown() { parent::tearDown(); Tree::__resetBootedStaticProperty(); } /** * New node saved as root * * @test */ public function can_create_new_node_as_root() { $root = new Tree(); $this->assertNotEmpty($root->setAsRoot()); // Should return this $this->assertTrue($root->isRoot(), 'Assert root node'); // Assert path and level set properly $this->assertEquals($root->id, 1); $this->assertEquals($root->path, $root->id . '/'); $this->assertEquals($root->level, 0); $this->assertEmpty($root->parent, 'Expected no parent'); $root2 = new Tree(); $this->assertNotEmpty($root2->save()); // Standard save - we expect root node $this->assertTrue($root2->isRoot(), 'Assert root node'); // Assert path, level and parent set properly $this->assertEquals($root2->id, 2); $this->assertEquals($root2->path, $root2->id . '/'); $this->assertEquals($root2->level, 0); $this->assertEmpty($root2->parent, 'Expected no parent'); } /** * New node saved as child * * @test */ public function can_create_new_node_as_child() { $root = with(new Tree())->setAsRoot(); $child = with(new Tree())->setChildOf($root); // Assert path, level and parent set properly $this->assertEquals($root->path . $child->id . '/', $child->path, 'Wrong children path!'); $this->assertEquals($root->level + 1, $child->level, 'Wrong children level!'); $this->assertEquals($root->id, $child->parent_id, 'Wrong children parent!'); $this->assertEquals($root->path, $child->parent->path, 'Wrong children parent!'); } /** * New node saved as sibling * * @test */ public function can_create_new_node_as_sibling() { $sibling = with(new Tree())->setAsRoot(); $node = with(new Tree())->setSiblingOf($sibling); // Assert path, level and parent set properly $this->assertEquals($node->id . '/', $node->path, 'Wrong sibling path!'); $this->assertEquals($sibling->level, $node->level, 'Wrong sibling level!'); $this->assertEquals($sibling->parent_id, $node->parent_id, 'Wrong sibling parent!'); $this->assertEquals($sibling->parent, $node->parent, 'Wrong sibling parent!'); } /** * Change existing node to root node * * @test */ public function testChangeNodeToRoot() { $root = with(new Tree())->setAsRoot(); $node = with(new Tree())->setChildOf($root); $this->assertEquals($root->path, $node->parent->path); $node->setAsRoot(); // Change node to became root $this->assertEmpty($node->parent, 'New root expected to have no parent'); $this->assertEquals($node->level, 0, 'Root node should have level set to 0'); $this->assertEquals($node->id . '/', $node->path, ' Root path should look like - root_id/'); $this->assertEquals($node->parent_id, null, 'New root parent_id expected to be NULL'); $this->assertEquals($node->parent, null, 'New root parent relation should be set to NULL'); } /** * Get all children for specific node * * @test */ public function can_find_children_for_node() { $root = with(new Tree())->setAsRoot(); $node = with(new Tree())->setChildOf($root); $node2 = with(new Tree())->setChildOf($root); $correct[] = $node; $correct[] = $node2; // Getting all children for this root foreach ($root->children as $key => $child) { $this->assertEquals($correct[$key]->path, $child->path); // Child path same as returned from children relation $this->assertEquals($correct[$key]->parent, $child->parent);// Child parent same as returned from children relation } // children becomes root node $newRoot = $node->setAsRoot(); $this->assertTrue($newRoot->isRoot(), 'Assert root node'); $this->assertEmpty($newRoot->parent, 'Expected no parent'); // Modify correct pattern $correct[0] = $node2; unset($correct[1]); // Getting all children for old root foreach ($root->children()->get() as $key => $child) { // We must refresh children relation $this->assertEquals($correct[$key]->path, $child->path); // Child path same as returned from children relation $this->assertEquals($correct[$key]->parent, $child->parent);// Child parent same as returned from children relation } $this->assertEquals([], $newRoot->children->toArray(), 'New Root expects to have no children'); } /** * Get all ancestors for specific node * * @test */ public function can_find_ancestors_for_node() { extract($this->_createSampleTree()); // Build sample data $this->assertEquals($child1_1->id, $child1_1_1->parent->id, 'Node expects to have a specific parent'); $correct = [ $root, $child1, $child1_1, $child1_1_1 ]; foreach ($child1_1_1->findAncestors()->get() as $key => $ancestor) { $this->assertEquals($correct[$key]->path, $ancestor->path); // Ancestor path same as returned from findAncestors() $this->assertEquals($correct[$key]->parent, $ancestor->parent);// Ancestor path same as returned from findAncestors() } } /** * Get all descendants for specific node * * @test */ public function can_get_all_descendants_for_node() { extract($this->_createSampleTree()); $this->assertEquals(0, $child1_1_1->children()->count(), 'Node expected to be leaf'); $correct = [ $child1, $child1_1, $child1_1_1 ]; foreach ($child1->findDescendants()->get() as $key => $descendant) { $this->assertEquals($correct[$key]->path, $descendant->path); // Same as returned from findDescendants() $this->assertEquals($correct[$key]->parent, $descendant->parent);// Same as returned from findDescendants() } } /** * Get root for specific node * * @test */ public function cat_find_root_node() { extract($this->_createSampleTree()); $this->assertEquals($root->toArray(), $child1_1_1->findRoot()->toArray(), 'Expected root node'); } /** * Recursive node updating * * @test */ public function can_move_sub_tree() { extract($this->_createAdvancedTree()); $this->assertEquals($child2_2->toArray(), $child2_2_1->parent->toArray(), 'Node expects to have a specific parent'); $this->assertEquals($child2_2_1->level, 3, 'Node expects to have a specific level'); // Move whole subtree $child2_2->setAsRoot(); $this->assertEquals(0, $child2_2->level, 'Node expects to have a specific level'); $this->assertEquals(1, with(Tree::find($child2_2_1->id))->level, 'Node expects to have a specific level'); $this->assertEquals(1, with(Tree::find($child2_2_2->id))->level, 'Node expects to have a specific level'); $this->assertEquals(2, with(Tree::find($child2_2_2_1->id))->level, 'Node expects to have a specific level'); $this->assertEquals( $child2_2->id, preg_replace('/\/.+/', '', with(Tree::find($child2_2_2_1->id))->path), 'Node expects to have a specific path' ); } /** * Tree building on PHP side * * @test */ public function can_build_complete_tree() { extract($this->_createAdvancedTree()); $treeRoot = $root->buildTree($root->findDescendants()->get()); $this->assertEquals($root->id, $treeRoot->id, 'Specific child expected'); $this->assertEquals($treeRoot->children[0]->id, $child1->id, 'Specific child expected'); $this->assertEquals($treeRoot->children[0]->children[0]->id, $child1_1->id, 'Specific child expected'); $this->assertEquals($treeRoot->children[0]->children[0]->children[0]->id, $child1_1_1->id, 'Specific child expected'); $this->assertEquals($treeRoot->children[1]->id, $child2->id, 'Specific child expected'); $this->assertEquals($treeRoot->children[1]->children[1]->children[0]->id, $child2_2_1->id, 'Specific child expected'); } /** * Tree building on PHP side * * @test */ public function can_build_sub_tree() { extract($this->_createAdvancedTree()); $treeRoot = $child1->buildTree($child1->findDescendants()->get()); $this->assertEquals($child1->id, $treeRoot->id, 'Specific child expected'); $this->assertEquals($treeRoot->children[0]->id, $child1_1->id, 'Specific child expected'); $this->assertEquals($treeRoot->children[0]->children[0]->id, $child1_1_1->id, 'Specific child expected'); } /** * Tree building on PHP side * * @test */ public function can_build_complete_trees() { extract($this->_createAdvancedTrees()); $nodes = $root->orderBy('level', 'ASC')->get(); // We get all nodes $treeRoots = $root->buildTree($nodes); // And we should build two trees $this->assertEquals(count($treeRoots), 2, 'We shoul have exactly 2 roots'); $this->assertEquals($treeRoots[0]->children[0]->id, $child1->id, 'Specific child expected'); $this->assertEquals($treeRoots[0]->children[0]->children[0]->id, $child1_1->id, 'Specific child expected'); $this->assertEquals($treeRoots[0]->children[0]->children[0]->children[0]->id, $child1_1_1->id, 'Specific child expected'); $this->assertEquals($treeRoots[0]->children[1]->id, $child2->id, 'Specific child expected'); $this->assertEquals($treeRoots[0]->children[1]->children[1]->children[0]->id, $child2_2_1->id, 'Specific child expected'); $this->assertEquals($treeRoots[1]->children[0]->id, $child4->id, 'Specific child expected'); $this->assertEquals($treeRoots[1]->children[0]->children[0]->id, $child4_1->id, 'Specific child expected'); $this->assertEquals($treeRoots[1]->children[0]->children[0]->children[0]->id, $child4_1_1->id, 'Specific child expected'); $this->assertEquals($treeRoots[1]->children[1]->id, $child5->id, 'Specific child expected'); $this->assertEquals($treeRoots[1]->children[1]->children[1]->children[0]->id, $child5_2_1->id, 'Specific child expected'); } /** * Tree building on PHP side * * @test */ public function it_returns_null_if_cant_build_tree() { extract($this->_createSampleTree()); $treeRoots = $root->buildTree(new \Illuminate\Database\Eloquent\Collection()); // Empty collection, so we can't build tree $this->assertNull($treeRoots); } /** * Tree building from array * * @test */ public function can_map_array() { Tree::mapArray( [ [ 'children' => [ [ 'children' => [ [ 'children' => [ [ 'children' => [] ], [ 'children' => [] ] ] ], [ 'children' => [] ] ] ], [ 'children' => [] ] ] ], [ 'children' => [] ], [ 'children' => [] ] ] ); $this->assertEquals(3, Tree::getRoots()->count(), 'Expected numer of Roots'); $this->assertEquals(7, Tree::find(1)->findDescendants()->count(), 'Expected numer of Descendants'); $this->assertEquals(2, Tree::find(1)->children()->count(), 'Expected numer of Children'); $this->assertEquals(4, Tree::find(5)->findAncestors()->count(), 'Expected numer of Ancestors'); // Most nested } /** * getting leaf nodes * * @test */ public function get_leaf_nodes() { extract($this->_createSampleTree()); $correct = [ $child2, $child3, $child1_1_1 ]; foreach($root->getLeaves()->get() as $key=>$node ) { $this->assertEquals($correct[$key]->toArray(),$node->toArray()); } } /** * getting leaf nodes if the tree is only one node(root) * * @test */ public function get_leaf_nodes_root_only() { $root= with(new Tree())->setAsRoot(); $correct = [ $root->toArray() ]; $this->assertEquals($correct,$root->getLeaves()->get()->toArray()); } /** * Define environment setup. * * @param Illuminate\Foundation\Application $app * * @return void */ protected function getEnvironmentSetUp($app) { // reset base path to point to our package's src directory $app['path.base'] = __DIR__ . '/../src'; $app['config']->set('database.default', 'testbench'); $app['config']->set( 'database.connections.testbench', [ 'driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '', ] ); } /** * Helper function * * @return array */ protected function _createSampleTree() { $tree = []; $tree['root'] = with(new Tree())->setAsRoot(); $tree['child1'] = with(new Tree())->setChildOf($tree['root']); $tree['child2'] = with(new Tree())->setChildOf($tree['root']); $tree['child3'] = with(new Tree())->setChildOf($tree['root']); $tree['child1_1'] = with(new Tree())->setChildOf($tree['child1']); $tree['child1_1_1'] = with(new Tree())->setChildOf($tree['child1_1']); return $tree; } /** * Helper function * * @return array */ protected function _createAdvancedTree() { $tree = []; $tree['root'] = with(new Tree())->setAsRoot(); $tree['child1'] = with(new Tree())->setChildOf($tree['root']); $tree['child2'] = with(new Tree())->setChildOf($tree['root']); $tree['child3'] = with(new Tree())->setChildOf($tree['root']); $tree['child1_1'] = with(new Tree())->setChildOf($tree['child1']); $tree['child2_1'] = with(new Tree())->setChildOf($tree['child2']); $tree['child2_2'] = with(new Tree())->setChildOf($tree['child2']); $tree['child1_1_1'] = with(new Tree())->setChildOf($tree['child1_1']); $tree['child2_2_1'] = with(new Tree())->setChildOf($tree['child2_2']); $tree['child2_2_2'] = with(new Tree())->setChildOf($tree['child2_2']); $tree['child2_2_2_1'] = with(new Tree())->setChildOf($tree['child2_2_2']); return $tree; } /** * Helper function * * @return array */ protected function _createAdvancedTrees() { $tree = []; $tree['root'] = with(new Tree())->setAsRoot(); $tree['child1'] = with(new Tree())->setChildOf($tree['root']); $tree['child2'] = with(new Tree())->setChildOf($tree['root']); $tree['child3'] = with(new Tree())->setChildOf($tree['root']); $tree['child1_1'] = with(new Tree())->setChildOf($tree['child1']); $tree['child2_1'] = with(new Tree())->setChildOf($tree['child2']); $tree['child2_2'] = with(new Tree())->setChildOf($tree['child2']); $tree['child1_1_1'] = with(new Tree())->setChildOf($tree['child1_1']); $tree['child2_2_1'] = with(new Tree())->setChildOf($tree['child2_2']); $tree['child2_2_2'] = with(new Tree())->setChildOf($tree['child2_2']); $tree['child2_2_2_1'] = with(new Tree())->setChildOf($tree['child2_2_2']); $tree['root2'] = with(new Tree())->setAsRoot(); $tree['child4'] = with(new Tree())->setChildOf($tree['root2']); $tree['child5'] = with(new Tree())->setChildOf($tree['root2']); $tree['child6'] = with(new Tree())->setChildOf($tree['root']); $tree['child4_1'] = with(new Tree())->setChildOf($tree['child4']); $tree['child5_1'] = with(new Tree())->setChildOf($tree['child5']); $tree['child5_2'] = with(new Tree())->setChildOf($tree['child5']); $tree['child4_1_1'] = with(new Tree())->setChildOf($tree['child4_1']); $tree['child5_2_1'] = with(new Tree())->setChildOf($tree['child5_2']); $tree['child5_2_2'] = with(new Tree())->setChildOf($tree['child5_2']); $tree['child5_2_2_1'] = with(new Tree())->setChildOf($tree['child5_2_2']); return $tree; } }
php
MIT
de4065b9ef3977702d62227bf9a5afccb710fa82
2026-01-05T05:19:45.893021Z
false
AdrianSkierniewski/eloquent-tree
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/tests/Model/Tree.php
tests/Model/Tree.php
<?php class Tree extends \Gzero\EloquentTree\Model\Tree { protected $fillable = ['title']; /** * ONLY FOR TESTS! * Metod resets static::$booted */ public static function __resetBootedStaticProperty() { static::$booted = []; } }
php
MIT
de4065b9ef3977702d62227bf9a5afccb710fa82
2026-01-05T05:19:45.893021Z
false
AdrianSkierniewski/eloquent-tree
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/tests/migrations/2013_12_17_105602_create_tree_table.php
tests/migrations/2013_12_17_105602_create_tree_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; class CreateTreeTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create( 'trees', function (Blueprint $table) { $table->increments('id'); $table->string('path', 255)->nullable(); $table->integer('parent_id')->unsigned()->nullable(); $table->integer('level')->default(0); $table->timestamps(); $table->index(array('path', 'parent_id')); $table->foreign('parent_id')->references('id')->on('trees')->on_delete('CASCADE'); } ); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::drop('trees'); } }
php
MIT
de4065b9ef3977702d62227bf9a5afccb710fa82
2026-01-05T05:19:45.893021Z
false
smuuf/primi
https://github.com/smuuf/primi/blob/d66ad6a397080a4caec9b634c925c0e085a00bb0/tools/phpcb-benchmarks/arrayiter_vs_yield.php
tools/phpcb-benchmarks/arrayiter_vs_yield.php
<?php require __DIR__ . "/../../vendor/autoload.php"; $bench = new \Smuuf\Phpcb\PhpBenchmark; $arr = array_combine(range(0, 50000), range(0, 50000)); function gen() { global $arr; foreach ($arr as $k => $v) { yield $k => $v; } } $bench->addBench(function() { $result = []; foreach (gen() as $k => $v) { $result[$k] = $v; } return $result; }); $bench->addBench(function() use ($arr) { $result = []; foreach (new \ArrayIterator($arr) as $k => $v) { $result[$k] = $v; } return $result; }); $bench->run(10000);
php
MIT
d66ad6a397080a4caec9b634c925c0e085a00bb0
2026-01-05T05:19:57.676815Z
false
smuuf/primi
https://github.com/smuuf/primi/blob/d66ad6a397080a4caec9b634c925c0e085a00bb0/tools/phpcb-benchmarks/is_round_int.php
tools/phpcb-benchmarks/is_round_int.php
<?php require __DIR__ . "/../../vendor/autoload.php"; $bench = new \Smuuf\Phpcb\PhpBenchmark; $data = [false, '+1', '-1', +1, 0, 1, 42, -1024, 0.2, -0.2, -0.7, 0.7, true, "ahoj", "0.1", "-4.2", "-4.7", "-1000000", "false", "75", "125", "111.1.4"]; $bench->addBench(function() use ($data) { $result = []; foreach ($data as $x) { $result[] = \is_numeric($x) && \preg_match('#^[+-]?\d+?$#', $x); } return $result; }); $bench->addBench(function() use ($data) { $result = []; foreach ($data as $x) { $result[] = \is_numeric($x) && \round((float) $x) == $x; } return $result; }); $bench->run(5e5);
php
MIT
d66ad6a397080a4caec9b634c925c0e085a00bb0
2026-01-05T05:19:57.676815Z
false