Download the PHP package hyvor/helper-laravel without Composer

On this page you can find all versions of the php package hyvor/helper-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package helper-laravel

internal

This package provides the following features for HYVOR applications in Laravel:

Installation

Install via composer:

Include ./vendor/hyvor/internal/extension.neon in your PHPStan config:

Auth

This library connects with the HYVOR Auth API to authenticate users. It supports the following providers:

Configuration

The following environment variables are supported. See config.php for configuration options. Environment variables should be set in the .env file.

ENV Description Default
AUTH_HYVOR_URL Public URL of the HYVOR instance. Users are redirected here for login and signup https://hyvor.com
AUTH_HYVOR_PRIVATE_URL If the HYVOR instance is on a private network, set this to the private URL. Otherwise, the public URL will be used. AUTH_HYVOR_URL
AUTH_HYVOR_API_KEY REQUIRED. The API key of the HYVOR instance. This is used to fetch user data. test-key

User Data

The AuthUser class is used to represent the user. It has the following properties:

Fetching Data

Use the following methods to fetch data by user ID, email, or username:

Auth check

To check if the user is logged in:

Redirects

Programmatic Redirects

Use the following methods to get redirects to login, signup, and logout pages:

By default, the user will be redirected to the current page after login or logout. You may also set the redirect parameter to redirect the user to a specific page after login or logout:

HTTP Redirects

The following routes are automatically added to the application for HTTP redirects:

All endpoints support a redirect parameter to redirect the user to a specific page/URL after login or logout.

Testing

In testing, the provider is always set to fake. The FakeProvider always generate dummy data for all requested ids, emails, and usernames. This is useful for testing. You may also set a database of users for the FakeProvider to return specific data for specific users as follows:

When a database is set, the FakeProvider will return the user data from that database only. This is useful for testing the following scenarios:

In most other cases, you should be able to use the Fake provider without setting a database. Because it automatically generates dummy data for all users, you do not need to seed a database before each test case. However, note that user's data will be different for each test case.

Billing

License and plan classes should be added to the internal library.

Create Subscription Intent

Create a new subscription intent with the latest plan version.

Get License

You would usually get the license to check if a user/resource has access to a certain feature.

This function gets the license in the following order:

If no license was found, null is returned.

Resources

When a user creates a resource in the component (ex: a blog in HB), it should call Resource::register() within a transaction to register that resource in the core. Core will start the trial for the user if that's the first resource of the user in that component.

Local Development

To ease local development, this package is configured to mock Auth and Billing services so that you can develop without running the core. This feature is enabled by the src/InternalFake.php file, which has the following methods:

If you need to customize the fake data,

HTTP

This library provides a few helpers for handling HTTP requests.

Exceptions

HttpException

Use Hyvor\Internal\Http\Exceptions\HttpException to throw an HTTP exception. This is, in most cases, this error will be sent to the client in the JSON response. Therefore, only use this in middleware and controllers (never in domains). Never share sensitive information in the message.

Middleware

Auth Middleware

Use Hyvor\Internal\Http\Middleware\AuthMiddleware to require authentication for a route.

If the user is not logged in, an HttpException is thrown with status code 401. If the user is logged in, an AccessAuthUser object (extends AuthUser) is added to the service container, which can be used as follows:

Routes

Here's a list of routes added by this library:

Models

HasUser Trait

You may add the Hyvor\Internal\Auth\HasUser trait to any model to add a user() method to it. This method returns the AuthUser object, using the user_id column of the model.

Internationalization

This library provides some helpers to handle internationalization. Most of the time, strings are used in the front-end in HYVOR apps, but for some cases like emails, you may need to translate strings in the back-end. Similar to our Design System, we use the ICU message format. Therefore, you can share the same translations between the front-end and back-end.

All JSON translation files should be places in a directory, which is set in the config file. The default directory is resources/lang. The file name should be the language code (e.g. en-US.json). The file should be a JSON object with keys as the message IDs and values as the translations. Nested keys are also supported. The locales are loaded from the files in the directory.

Metrics

To enable metrics, add the middleware to global middleware in app/Http/Kernel.php:

The middleware will automatically do the following:

The apcu extension is required to persist metrics between requests. This has been tested with FrankenPHP. It does not work with the CLI.

Usage

The locale is matched to the closest available locale. For example, if you have the following locales:

You can also use the ClosestLocale class to get the closest locale to a given locale.

The I18n singleton class is the base class that manages the locales in the app.


All versions of helper-laravel with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-intl Version *
ext-apcu Version *
guzzlehttp/guzzle Version ^7.8
timacdonald/log-fake Version ^v2.3.0
promphp/prometheus_client_php Version ^2.14
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hyvor/helper-laravel contains the following files

Loading the files please wait ....