1. Go to this page and download the library: Download hyvor/internal library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hyvor / internal example snippets
use Hyvor\Internal\Auth\AuthUser;
// new instance
new AuthUser(
id: $id,
name: $name,
...
);
// from array
AuthUser::fromArray([
'id' => $id,
'name' => $name
])
use Hyvor\Internal\Auth\AuthUser;
AuthUser::fromId($id);
AuthUser::fromIds($ids);
AuthUser::fromEmail($email);
AuthUser::fromEmails($emails);
AuthUser::fromUsername($username);
AuthUser::fromUsernames($usernames);
use Hyvor\Internal\Auth\Auth;
// AuthUser|null
$user = Auth::check();
if ($user) {
// user is logged in
}
use Hyvor\Internal\Auth\Auth;
$loginUrl = Auth::login('/console');
// or full URL
$loginUrl = Auth::login('https://talk.hyvor.com/console');
use Hyvor\Internal\Auth\Providers\Fake\FakeProvider;
it('adds names to the email', function() {
// set the database of users
FakeProvider::databaseSet([
[
'id' => 1,
'name' => 'John Doe',
]
]);
// send email to user ID 1
// then assert
expect($email->body)->toContain('John Doe');
});
use Hyvor\Internal\Http\Exceptions\HttpException;
throw new HttpException('User not found', 404);
use Hyvor\Internal\Http\Middleware\AuthMiddleware;
Route::get()->middleware(AuthMiddleware::class);
use Hyvor\Internal\Http\Middleware\AccessAuthUser;
class MyController
{
public function index(AccessAuthUser $user) {
// $user is an instance of AccessAuthUser (extends AuthUser)
}
}
function myFunction() {
$user = app(AccessAuthUser::class);
}
class Post extends Model
{
use HasUser;
}
use Hyvor\Internal\Internationalization\Strings;
$strings = new Strings('en-US');
$welcome = $strings->get('welcome');
$email = $strings->get('email', ['email' => '[email protected]']);
$signupTitle = $strings->get('signup.title');
new Strings('en');; // locale -> `en-US`
new Strings('en-GB'); // locale -> `en-US`
new Strings('fr-FR'); // locale -> `fr-FR`
new Strings('fr'); // locale -> `fr-FR`
new Strings('es-ES'); // locale -> `es`
use Hyvor\Internal\Internationalization\ClosestLocale;
ClosestLocale::get('en', ['en-US', 'fr-FR', 'es']); // returns `en-US`
use Hyvor\Internal\Internationalization\I18n;
$i18n = app(I18n::class);
$i18n->getAvailableLocales(); // ['en-US', 'fr-FR', 'es', ...]
$i18n->getLocaleStrings('en-US'); // returns the strings from the JSON file as an array
$i18n->getDefaultLocaleStrings(); // strings of the default locale
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.