### Setup Database Notifications Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/notification.md Install the database package, publish the migration, run migrations, and generate a new notification class for database notifications. ```shell # Install the database package composer require hyperf/database:~3.2.0 # Publish the migration file php bin/hyperf.php notification:table # Run the migration php bin/hyperf.php migrate # Create a notification php bin/hyperf.php gen:notification TestNotification ``` -------------------------------- ### Install and Check Documentation Source: https://github.com/friendsofhyperf/components/blob/main/AGENTS.md Install project dependencies and run a documentation check to validate locale page parity, heading structures, component installation commands, and local links. ```bash npm install npm run docs:check ``` -------------------------------- ### Install Optional Facade Packages Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/facade.md Install additional packages required by specific facades your application will use. For example, to use the `Config` and `Log` facades, install their respective packages. ```shell composer require hyperf/config hyperf/logger ``` -------------------------------- ### Install Telescope Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/telescope.md Install the Telescope component using Composer. ```shell composer require friendsofhyperf/telescope ``` -------------------------------- ### Install Facade Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/facade.md Install the base facade component using Composer. This command also installs required dependencies like `friendsofhyperf/support`, `hyperf/context`, and `hyperf/di`. ```shell composer require friendsofhyperf/facade ``` -------------------------------- ### Install All Components Source: https://github.com/friendsofhyperf/components/blob/main/README.md Use this command to install the entire collection of FriendsOfHyperf components. ```bash composer require friendsofhyperf/components ``` -------------------------------- ### Install Specific Components Source: https://github.com/friendsofhyperf/components/blob/main/README.md Install only the components your application requires by specifying their names. ```bash composer require friendsofhyperf/telescope composer require friendsofhyperf/http-client composer require friendsofhyperf/model-factory --dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/friendsofhyperf/components/blob/main/README.md Install all project dependencies from the repository root using Composer. ```bash composer install ``` -------------------------------- ### Install Command Benchmark Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/command-benchmark.md Install the command benchmark component using Composer. ```shell composer require friendsofhyperf/command-benchmark ``` -------------------------------- ### Install Hyperf Helpers Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/helpers.md Install the Hyperf Helpers component using Composer. ```shell composer require friendsofhyperf/helpers ``` -------------------------------- ### Install Sentry Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/sentry.md Install the Sentry component using Composer. ```shell composer require friendsofhyperf/sentry ``` -------------------------------- ### Install Macros Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/macros.md Install the macros component using Composer. ```shell composer require friendsofhyperf/macros ``` -------------------------------- ### Publish Configuration and Example Files Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/model-factory.md Publish the configuration and example factory files to your project using the Hyperf console command. ```shell php bin/hyperf.php vendor:publish friendsofhyperf/model-factory ``` -------------------------------- ### Install IDE Helper Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/ide-helper.md Install the IDE Helper component using Composer. ```shell composer require friendsofhyperf/ide-helper ``` -------------------------------- ### Install OpenAI Client Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/openai-client.md Install the OpenAI client component using Composer. ```shell composer require friendsofhyperf/openai-client ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/friendsofhyperf/components/blob/main/README.md Install Node.js dependencies required for documentation checks. ```bash npm install ``` -------------------------------- ### Install Optional Closure Package Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/encryption.md Install the 'opis/closure' package if encrypted closures need to be signed. ```shell composer require opis/closure ``` -------------------------------- ### Install Support Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/support.md Install the FriendsOfHyperf Support component using Composer. Optional integrations for AMQP, Kafka, and async queues require installing their respective Hyperf packages. ```shell composer require friendsofhyperf/support ``` -------------------------------- ### IDE Helper Configuration Example Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/ide-helper.md Example configuration file for the IDE Helper component, demonstrating settings for model and macro generation. ```php [ 'ignores' => [ App\Model\InternalModel::class, ], 'camel_case_properties' => false, 'type_overrides' => [ 'integer' => 'int', ], 'custom_db_types' => [ 'mysql' => [ 'tinyint' => 'integer', ], ], ], 'macro' => [ 'namespaces' => [ 'App\\', ], 'rejects' => [ App\Example\RejectedMacroable::class, ], ], ]; ``` -------------------------------- ### Install Co-PHPUnit Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/co-phpunit.md Install the package as a development dependency using Composer. ```bash composer require friendsofhyperf/co-phpunit --dev ``` -------------------------------- ### Start Hyperf Application Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/web-tinker.md Start the Hyperf application server. Ensure the application is running to access Web Tinker. ```shell php bin/hyperf.php start ``` -------------------------------- ### Install OAuth2 Server Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/oauth2-server.md Install the OAuth2 Server component and publish its configuration and migrations. ```shell composer require friendsofhyperf/oauth2-server php bin/hyperf.php vendor:publish friendsofhyperf/oauth2-server php bin/hyperf.php migrate ``` -------------------------------- ### Install Hyperf Database Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/model-observer.md If you are using Hyperf models, ensure the hyperf/database component is installed. ```shell composer require hyperf/database ``` -------------------------------- ### Install OAuth2 Server Package Source: https://github.com/friendsofhyperf/components/blob/main/src/oauth2-server/README.md Install the FriendsOfHyperf OAuth2 Server package using Composer. ```bash composer require friendsofhyperf/oauth2-server ``` -------------------------------- ### Install Amqp Job Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/amqp-job.md Install the friendsofhyperf/amqp-job component using Composer. ```shell composer require friendsofhyperf/amqp-job ``` -------------------------------- ### Install Notification Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/notification.md Install the Hyperf Notification component using Composer. ```shell composer require friendsofhyperf/notification ``` -------------------------------- ### Install TCP Sender Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/tcp-sender.md Install the TCP sender component using Composer. ```shell composer require friendsofhyperf/tcp-sender ``` -------------------------------- ### Install Optional Dependencies for Flexible Cache Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/cache.md Install the necessary packages for the stale-while-revalidate caching feature. ```shell composer require friendsofhyperf/lock hyperf/coroutine ``` -------------------------------- ### Install gRPC Validation Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/grpc-validation.md Install the gRPC Validation component using Composer. This command also installs necessary Hyperf dependencies. ```shell composer require friendsofhyperf/grpc-validation ``` -------------------------------- ### Install Hyperf Tinker Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/tinker.md Install the Hyperf Tinker component using Composer. ```shell composer require friendsofhyperf/tinker ``` -------------------------------- ### Install Elasticsearch Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/elasticsearch.md Install the Elasticsearch component using Composer and publish its configuration file. ```shell composer require friendsofhyperf/elasticsearch php bin/hyperf.php vendor:publish friendsofhyperf/elasticsearch ``` -------------------------------- ### Install Confd Component and Drivers Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/confd.md Install the Confd component using Composer. You also need to install the driver package for the configuration source you intend to use (e.g., hyperf/etcd or hyperf/nacos). ```shell composer require friendsofhyperf/confd composer require hyperf/etcd # or composer require hyperf/nacos ``` -------------------------------- ### Install Redis Subscriber Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/redis-subscriber.md Install the Redis Subscriber component using Composer. ```shell composer require friendsofhyperf/redis-subscriber ``` -------------------------------- ### Start Tinker REPL Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/tinker.md Launch the Hyperf Tinker REPL tool from the command line. ```shell php bin/hyperf.php tinker ``` -------------------------------- ### Install Telescope Elasticsearch Driver Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/telescope-elasticsearch.md Install the Telescope Elasticsearch driver using Composer. ```shell composer require friendsofhyperf/telescope-elasticsearch ``` -------------------------------- ### Install Web Tinker Component (Alternative) Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/web-tinker.md An alternative command to install the Web Tinker component, which may also publish assets. ```shell php bin/hyperf.php web-tinker:install ``` -------------------------------- ### Install Console Spinner Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/console-spinner.md Install the console spinner component using Composer. ```shell composer require friendsofhyperf/console-spinner ``` -------------------------------- ### Install Mail Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/mail.md Install the mail component using Composer and publish its configuration and view files. ```shell composer require friendsofhyperf/mail php bin/hyperf.php vendor:publish friendsofhyperf/mail ``` -------------------------------- ### Install Encryption Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/encryption.md Install the Hyperf Encryption component using Composer. ```shell composer require friendsofhyperf/encryption ``` -------------------------------- ### Install Model Morph Addon Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/model-morph-addon.md Install the Model Morph Addon using Composer. ```shell composer require friendsofhyperf/model-morph-addon ``` -------------------------------- ### Install Rate Limit Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/rate-limit.md Install the Hyperf rate limit component using Composer. ```bash composer require friendsofhyperf/rate-limit ``` -------------------------------- ### Install Notification Mail Channel Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/notification-mail.md Install the notification mail component using Composer. ```shell composer require friendsofhyperf/notification-mail ``` -------------------------------- ### Install Purifier Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/purifier.md Install the Purifier component using Composer. The service provider is automatically discovered. ```shell composer require friendsofhyperf/purifier ``` -------------------------------- ### Install Model Observer Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/model-observer.md Install the Model Observer component using Composer. This is the first step to enable model event observation. ```shell composer require friendsofhyperf/model-observer ``` -------------------------------- ### OAuth2 Server Configuration Example Source: https://github.com/friendsofhyperf/components/blob/main/src/oauth2-server/README.md Example configuration for the FriendsOfHyperf OAuth2 Server, detailing various grant types, token lifetimes, and security settings. ```php [ # Full path to the private key file. # How to generate a private key: https://oauth2.thephpleague.com/installation/#generating-public-and-private-keys 'private_key' => env('OAUTH2_PRIVATE_KEY'), # Passphrase of the private key, if any 'private_key_passphrase' => env('OAUTH2_PRIVATE_KEY_PASSPHRASE'), # The plain string or the ascii safe string used to create a Defuse\Crypto\Key to be used as an encryption key. # How to generate an encryption key: https://oauth2.thephpleague.com/installation/#string-password 'encryption_key' => env('OAUTH2_ENCRYPTION_KEY'), # The encryption key type. 'encryption_key_type' => EncryptionKeyType::from(env('OAUTH2_ENCRYPTION_KEY_TYPE', 'plain')), 'response_type' => BearerTokenResponse::class, # Whether to revoke refresh tokens after they were used for all grant types (default to true) 'revoke_refresh_tokens' => true, # How long the issued access token should be valid for. # The value should be a valid interval: http://ph 'access_token_ttl' => new DateInterval('PT1H'), # How long the issued auth code should be valid for. # The value should be a valid interval: http://php.net/manual/en/dateinterval.construct.php#refsect1-dateinterval.construct-parameters 'auth_code_ttl' => new DateInterval('PT10M'), # How long the issued refresh token should be valid for. # The value should be a valid interval: http://php.net/manual/en/dateinterval.construct.php#refsect1-dateinterval.construct-parameters 'refresh_token_ttl' => new DateInterval('P1M'), # Whether to enable the client credentials grant 'enable_client_credentials_grant' => true, # Whether to enable the password grant 'enable_password_grant' => true, # Whether to enable the refresh token grant 'enable_refresh_token_grant' => true, # Whether to enable the authorization code grant 'enable_auth_code_grant' => true, 'enable_implicit_grant' => false, # Whether to require code challenge for public clients for the auth code grant 'require_code_challenge_for_public_clients' => true, # Whether to enable access token saving to persistence layer (default to true) 'persist_access_token' => true, ], 'resource_server' => [ # Full path to the public key file # How to generate a public key: https://oauth2.thephpleague.com/installation/#generating-public-and-private-keys 'public_key' => env('OAUTH2_PUBLIC_KEY'), # The leeway in seconds to allow for clock skew in JWT verification. Default PT0S (no leeway). 'jwt_leeway' => null, ], 'scopes' => [ # Scopes that you wish to utilize in your application. # This should be a simple array of strings. 'available' => [], # Scopes that will be assigned when no scope given. # This should be a simple array of strings. 'default' => [], ], ]; ``` -------------------------------- ### Install Pretty Console Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/pretty-console.md Install the Pretty Console component using Composer. This command adds the necessary package to your Hyperf project. ```shell composer require friendsofhyperf/pretty-console ``` -------------------------------- ### Install Model Hashids Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/model-hashids.md Install the Model Hashids component using Composer. This command fetches the package and its dependencies. ```shell composer require friendsofhyperf/model-hashids ``` -------------------------------- ### Install Hyperf Mail Component Source: https://github.com/friendsofhyperf/components/blob/main/src/mail/README.md Install the mail component using Composer and publish its configuration files. Ensure Hyperf view configuration is also published if not already present. ```shell composer require friendsofhyperf/mail php bin/hyperf.php vendor:publish friendsofhyperf/mail ``` ```shell php bin/hyperf.php vendor:publish hyperf/view ``` -------------------------------- ### Install Fast Paginate Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/fast-paginate.md Install the Fast Paginate component using Composer. It depends on Hyperf 3.2 packages and requires no additional configuration. ```shell composer require friendsofhyperf/fast-paginate ``` -------------------------------- ### Install Web Tinker Package Source: https://github.com/friendsofhyperf/components/blob/main/src/web-tinker/README.md Use Composer to install the Web Tinker package into your Hyperf project. ```shell composer require friendsofhyperf/web-tinker ``` -------------------------------- ### Install IPC Broadcaster Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/ipc-broadcaster.md Install the IPC Broadcaster component using Composer. The package automatically registers its configuration and listeners. ```shell composer require friendsofhyperf/ipc-broadcaster ``` -------------------------------- ### Install Hyperf Cache Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/cache.md Install the component using Composer. This component requires Hyperf 3.2. ```shell composer require friendsofhyperf/cache ``` -------------------------------- ### Install Web Tinker Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/web-tinker.md Install the Web Tinker component using Composer. This is a development dependency. ```shell composer require friendsofhyperf/web-tinker --dev ``` -------------------------------- ### Benchmark Summary Output Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/command-benchmark.md Example of the colored summary output displayed after a benchmarked command completes. ```text ⚡ TIME: 2.5s MEM: 15.23MB SQL: 42 ``` -------------------------------- ### Model Annotation After Addon Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/mysql-grammar-addon.md Example of a generated model annotation with preserved non-ASCII comments after installing the MySQL Grammar Addon. ```php /** * @property int $user_id 用户id * @property string $event_name 事件名称 */ ``` -------------------------------- ### Install MySQL Grammar Addon Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/mysql-grammar-addon.md Install the MySQL Grammar Addon using Composer. This package requires specific versions of hyperf/database and hyperf/di. ```shell composer require friendsofhyperf/mysql-grammar-addon --dev ``` -------------------------------- ### Model Annotation Before Addon Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/mysql-grammar-addon.md Example of a generated model annotation with garbled non-ASCII comments before installing the MySQL Grammar Addon. ```php /** * @property int $user_id ??id * @property string $event_name ???? */ ``` -------------------------------- ### Install Command Validation Package Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/command-validation.md Install the package using Composer. This package requires Hyperf `~3.2.0` and `hyperf/validation`. ```shell composer require friendsofhyperf/command-validation ``` -------------------------------- ### Access Named Cache Repository via Factory Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/cache.md Inject the Contract\Factory interface to access named cache stores. The example shows how to get a 'redis' store. ```php use FriendsOfHyperf\Cache\Contract\Factory; $cache = $factory->store('redis'); ``` -------------------------------- ### Login Rate Limiting Example Source: https://github.com/friendsofhyperf/components/blob/main/src/rate-limit/README.md Implement rate limiting for login attempts to prevent brute-force attacks. This example limits to 5 attempts within 5 minutes. ```php #[RateLimit( key: 'login:{email}', maxAttempts: 5, decay: 300, // 5 minutes response: 'Too many login attempts. Please try again after 5 minutes.', responseCode: 429 )] public function login(string $email, string $password) { // Login logic here } ``` -------------------------------- ### Install HTTP Client and Guzzle Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/http-client.md Install the Hyperf HTTP Client component and Guzzle using Composer. Guzzle is a required dependency for sending requests. ```shell composer require friendsofhyperf/http-client guzzlehttp/guzzle:^7.6 ``` -------------------------------- ### Install Config Consul Package Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/config-consul.md Install the Hyperf Config Consul package using Composer. This command also installs its dependencies. ```shell composer require friendsofhyperf/config-consul ``` -------------------------------- ### Install Exception Event Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/exception-event.md Install the component using Composer. Ensure Hyperf's DI and event components are available for AOP and event dispatcher support. ```shell composer require friendsofhyperf/exception-event ``` -------------------------------- ### Login Rate Limiting Example Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/rate-limit.md Implement rate limiting for login attempts to prevent brute-force attacks. This example limits attempts to 5 within 5 minutes and customizes the response message and code. ```php ``` -------------------------------- ### Run Telescope Database Migrations Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/telescope.md Execute database changes to create and store data required by Telescope. ```shell php bin/hyperf.php migrate ``` -------------------------------- ### Example ConfigProvider Structure Source: https://github.com/friendsofhyperf/components/blob/main/CLAUDE.md Illustrates the structure of a ConfigProvider class used for Hyperf component auto-discovery. It defines dependencies, commands, listeners, aspects, annotations, and publishable assets. ```php namespace FriendsOfHyperf\ComponentName; class ConfigProvider { public function __invoke(): array { return [ 'dependencies' => [], // DI container bindings 'commands' => [], // Console commands 'listeners' => [], // Event listeners 'aspects' => [], // AOP aspects 'annotations' => [ 'scan' => [ 'paths' => [__DIR__], ], ], 'publish' => [], // Publishable assets ]; } } ``` -------------------------------- ### Enable Benchmark Option Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/command-benchmark.md Invoke a Hyperf command with the --enable-benchmark flag to activate performance metrics. ```shell php bin/hyperf.php your:command --enable-benchmark ``` -------------------------------- ### Install ReCaptcha Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/recaptcha.md Use Composer to install the ReCaptcha component for your Hyperf project. ```shell composer require friendsofhyperf/recaptcha ``` -------------------------------- ### Redis Configuration Example Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/rate-limit.md Configure multiple Redis connection pools in config/autoload/redis.php, including a dedicated pool for rate limiting with specific connection settings. ```php return [ 'default' => [ 'host' => env('REDIS_HOST', 'localhost'), 'port' => env('REDIS_PORT', 6379), 'auth' => env('REDIS_AUTH', null), 'db' => 0, 'pool' => [ 'min_connections' => 1, 'max_connections' => 30, ], ], 'rate_limit' => [ 'host' => env('REDIS_HOST', 'localhost'), 'port' => env('REDIS_PORT', 6379), 'auth' => env('REDIS_AUTH', null), 'db' => 1, 'pool' => [ 'min_connections' => 5, 'max_connections' => 50, ], ], ]; ``` -------------------------------- ### Accessing Underlying Object and Configuration Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/facade.md Demonstrates how to retrieve the underlying object of a facade using `getFacadeRoot()` and how to access configuration values through the facade. ```php use FriendsOfHyperf\Facade\Config; $config = Config::getFacadeRoot(); $name = Config::get('app_name', 'hyperf'); ``` -------------------------------- ### Setup Model with HasHashid and HashidRouting Traits Source: https://github.com/friendsofhyperf/components/blob/main/src/model-hashids/README.md To enable basic hashid features and route binding, use the HasHashid and HashidRouting traits in your model. This integrates hashid generation and resolution directly into your model. ```php use Hyperf\Database\Model\Model; use FriendsOfHyperf\ModelHashids\Concerns\HasHashid; use FriendsOfHyperf\ModelHashids\Concerns\HashidRouting; Class Item extends Model { use HasHashid, HashidRouting; } ``` -------------------------------- ### Install Symfony Mailer Source: https://github.com/friendsofhyperf/components/blob/main/src/notification/README.md Install the Symfony Mailer component using Composer. This is a prerequisite for email notifications. ```shell composer require symfony/mailer ``` -------------------------------- ### Basic Usage of Pretty Console Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/pretty-console.md Demonstrates how to use the Pretty Console component within a Hyperf command. It utilizes the Prettyable trait to format console output. ```php components->info('Your message here.'); } } ``` -------------------------------- ### Navigate to a Component Directory Source: https://github.com/friendsofhyperf/components/blob/main/CLAUDE.md Change the current directory to work on a specific component, such as 'telescope'. ```bash cd src/telescope ``` -------------------------------- ### Install Model Factory Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/model-factory.md Install the Model Factory component using Composer. This package is intended for development environments. ```shell composer require friendsofhyperf/model-factory --dev ``` -------------------------------- ### Publish Telescope Configuration Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/telescope-elasticsearch.md Publish the Telescope configuration file to your project. ```shell php bin/hyperf.php vendor:publish friendsofhyperf/telescope --id=config ``` -------------------------------- ### Setup Model with HasHashid and HashidRouting Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/model-hashids.md Add the HasHashid concern to your model to enable hashid encoding/decoding. Include HashidRouting if you want implicit route binding to use hashids. ```php use FriendsOfHyperf\ModelHashids\Concerns\HasHashid; use FriendsOfHyperf\ModelHashids\Concerns\HashidRouting; use Hyperf\Database\Model\Model; class Item extends Model { use HasHashid; use HashidRouting; } ``` -------------------------------- ### Install Trigger Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/trigger.md Install the Trigger component using Composer. This command adds the necessary package to your project dependencies. ```shell composer require friendsofhyperf/trigger ``` -------------------------------- ### Create Elasticsearch Client with Options Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/elasticsearch.md Uses ClientBuilderFactory to create an Elasticsearch client builder, passing Guzzle options and setting hosts before building the client. ```php use FriendsOfHyperf\Elasticsearch\ClientBuilderFactory; class Foo { public function __construct(protected ClientBuilderFactory $clientBuilderFactory) { } public function handle() { $client = $this->clientBuilderFactory ->create(['timeout' => 5]) ->setHosts(['http://127.0.0.1:9200']) ->build(); return $client->info(); } } ``` -------------------------------- ### Install Notification EasySms Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/notification-easysms.md Install the component using Composer. It automatically handles dependencies like friendsofhyperf/notification and overtrue/easy-sms. ```shell composer require friendsofhyperf/notification-easysms ``` -------------------------------- ### Importing and Using Helper Functions Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/helpers.md Demonstrates how to import and use common helper functions like literal, object_get, blank, and transform. Ensure these functions are imported from the FriendsOfHyperf\Helpers namespace before use. ```php use function FriendsOfHyperf\Helpers\blank; use function FriendsOfHyperf\Helpers\literal; use function FriendsOfHyperf\Helpers\object_get; use function FriendsOfHyperf\Helpers\transform; $profile = literal(name: 'Taylor', contact: (object) ['email' => 'taylor@example.com']); object_get($profile, 'contact.email'); // taylor@example.com blank(' '); // true transform(5, fn (int $value) => $value * 2); // 10 ``` -------------------------------- ### Install Compoships Component Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/compoships.md Install the Compoships component using Composer. This command adds the necessary package to your project dependencies. ```shell composer require friendsofhyperf/compoships ``` -------------------------------- ### Viewing Documentation for a Function in Tinker Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/tinker.md Attempts to display documentation for the `md5` function. Requires the PHP manual to be downloaded for full details. ```shell >>> doc md5 function md5($str, $raw_output = unknown) PHP manual not found To document core PHP functionality, download the PHP reference manual: https://github.com/bobthecow/psysh/wiki/PHP-manual >>> ``` -------------------------------- ### Install Command Signals Package Source: https://github.com/friendsofhyperf/components/blob/main/docs/en/components/command-signals.md Install the command signals package using Composer. This package is automatically discovered and does not publish configuration. ```shell composer require friendsofhyperf/command-signals ``` -------------------------------- ### Building AuthorizationServer via Factory Source: https://github.com/friendsofhyperf/components/blob/main/src/oauth2-server/README.md Use the AuthorizationServerFactory to build an instance of the AuthorizationServer. This is the recommended approach for obtaining the server instance in your code. ```php authorizationServerFactory->build(); // Use the authorization server for token validation, etc. // ... } } ```