VOOZH about

URL: https://deepwiki.com/hypervel/support/2-getting-started

⇱ Getting Started | hypervel/support | DeepWiki


Loading...
Menu

Getting Started

This guide covers installation, configuration, and initial usage of the hypervel/support package. It provides step-by-step instructions for integrating the package into your Hypervel or Hyperf application, understanding its dependencies, and making your first calls to facades and helper functions.

For architectural details about the package's design patterns, see Core Architecture. For comprehensive references to specific subsystems like HTTP, data persistence, or views, see their respective sections (HTTP Layer, Data Persistence Layer, View Layer).


Requirements

The hypervel/support package has the following requirements:

RequirementVersionPurpose
PHP^8.2Minimum PHP version
hyperf/context~3.1.0Context management for coroutines
hyperf/support~3.1.0Base Hyperf utilities
hyperf/stringable~3.1.0String manipulation
hyperf/tappable~3.1.0Fluent method chaining
hyperf/collection~3.1.0Collection utilities
nesbot/carbon^2.72.6Date and time handling
league/uri^7.5URI manipulation

Sources: composer.json22-31


Installation

Step 1: Install via Composer

Add the package to your project using Composer:


The package will automatically install all required dependencies listed above.

Step 2: Verify Autoloading

The package uses PSR-4 autoloading for the Hypervel\Support namespace and automatically loads two function files:

  • src/Functions.php - Core function definitions
  • src/helpers.php - Global helper functions (~40 utilities)

These files are loaded automatically when Composer's autoloader is initialized.

Installation Flow Diagram


Sources: composer.json32-40


Package Structure and Integration

The hypervel/support package integrates into your application through multiple layers:

Integration Architecture Diagram


Sources: composer.json1-50 src/ServiceProvider.php1-50


Basic Usage

Using Facades

Facades provide a static interface to services registered in the container. Here are the primary facades available:

FacadePurposeExample Usage
Hypervel\Support\Facades\RequestAccess HTTP request dataRequest::input('name')
Hypervel\Support\Facades\ResponseGenerate HTTP responsesResponse::json(['status' => 'ok'])
Hypervel\Support\Facades\DBDatabase operationsDB::table('users')->get()
Hypervel\Support\Facades\CacheCaching operationsCache::get('key')
Hypervel\Support\Facades\ViewRender viewsView::make('welcome')
Hypervel\Support\Facades\RouteDefine routesRoute::get('/home', [HomeController::class, 'index'])
Hypervel\Support\Facades\EventDispatch eventsEvent::dispatch(new OrderShipped($order))
Hypervel\Support\Facades\QueueQueue jobsQueue::push(new ProcessOrder($order))

Example: Using Request and Response Facades


For complete facade documentation, see Facade System.

Sources: High-level architectural diagrams (Facade Layer), Diagram 2

Using Helper Functions

The package provides approximately 40 global helper functions for common tasks:

Data Manipulation


Environment and Configuration


String Utilities


Control Flow


For a complete reference of all helper functions, see Helper Functions.

Sources: composer.json36-39 src/helpers.php (referenced but not included in files)


Service Provider Registration

Understanding Service Providers

Service providers are the central mechanism for bootstrapping services in the application. The ServiceProvider abstract class provides methods for:

  • Registering services in the container
  • Loading resources (routes, views, translations, migrations)
  • Publishing assets (configuration files, public assets)
  • Extending the framework with custom functionality

Service Provider Lifecycle Diagram


Sources: src/ServiceProvider.php17-92

Creating a Custom Service Provider

If you're building a package that extends the Hypervel framework, extend Hypervel\Support\ServiceProvider:


Key ServiceProvider Methods

MethodPurposeTypical Usage
register()Bind services to containerService registration, configuration merging
boot()Bootstrap after registrationLoad routes, views, migrations, translations
mergeConfigFrom(string $path, string $key)Merge package config with app configServiceProvider.php97-104
loadRoutesFrom(string $path)Register route fileServiceProvider.php109-113
loadViewsFrom($path, string $namespace)Register view namespaceServiceProvider.php118-130
loadTranslationsFrom(string $path, string $namespace)Register translation namespaceServiceProvider.php147-152
loadMigrationsFrom($paths)Register migration pathsServiceProvider.php167-174
publishes(array $paths, $groups)Define publishable assetsServiceProvider.php206-215

Sources: src/ServiceProvider.php54-240

Default Providers

The package includes a DefaultProviders collection that defines the core service providers:

Default Providers Structure


The DefaultProviders class provides methods to customize the provider collection:

  • merge(array $providers) - Add additional providers
  • replace(array $replacements) - Replace specific providers
  • except(array $providers) - Remove specific providers

Sources: src/DefaultProviders.php1-69 src/ServiceProvider.php327-330


Directory Structure

Understanding the package's internal structure:

hypervel/support/
├── src/
│ ├── Facades/ # Static facade classes
│ ├── ServiceProvider.php # Base service provider class
│ ├── DefaultProviders.php # Default provider collection
│ ├── Functions.php # Core function definitions
│ ├── helpers.php # Global helper functions
│ ├── DataObject.php # Base data object class
│ ├── Manager.php # Base manager class
│ └── Collection.php # Collection utilities
└── composer.json # Package definition

Code Entity Mapping


Sources: composer.json32-40


Next Steps

Now that you have the package installed and understand the basics, explore the following sections:

TopicSectionDescription
Architecture DetailsCore ArchitectureDeep dive into facades, service providers, managers, and data objects
HTTP OperationsHTTP LayerRequest handling, responses, routing, HTTP client
Views and TemplatesView LayerBlade templating, view rendering, localization
Data PersistenceData Persistence LayerDatabase, cache, Redis, and queue operations
EventsEvents and BroadcastingEvent dispatching and real-time broadcasting
ValidationValidationInput validation and custom rules
UtilitiesUtilities and HelpersComplete reference of helper functions and utility classes
TestingTesting InfrastructureFakes, assertions, and testing patterns

Quick Reference: Common Tasks

TaskCode Example
Get request input$name = Request::input('name');
Return JSON responsereturn Response::json(['status' => 'ok']);
Query database$users = DB::table('users')->where('active', 1)->get();
Cache dataCache::put('key', 'value', 3600);
Render viewreturn View::make('welcome', ['name' => 'John']);
Dispatch eventEvent::dispatch(new OrderCreated($order));
Queue jobQueue::push(new SendEmail($user));
Create collection$collection = collect([1, 2, 3]);
Get nested data$value = data_get($data, 'user.profile.email');

Sources: High-level architectural diagrams (Overall System Architecture, Facade Ecosystem)