承接 elmyrockers/ezauth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elmyrockers/ezauth

Composer 安装命令:

composer require elmyrockers/ezauth

包简介

EzAuth PHP library - Lightweight & easy authentication library with secure 'remember me' feature for PHP. With this, you just need to write a few lines of PHP code only in each pages.

README 文档

README

Lightweight & easy authentication library with secure 'remember me' feature for PHP. With this, you just need to write a few lines of PHP code only in each pages.

Usage/Examples

1. Installation:

Install the EzAuth package using Composer:

composer require elmyrockers/ezauth

2. bootstrap.php:

Create bootstrap.php file. The complete code for this file should look like this:

// bootstrap.php
<?php
require_once 'vendor/autoload.php'; //Include composer's autoloader
use elmyrockers\EzAuth; // Use EzAuth package

$config = []; // Create an array contain configuration for our authentication
$auth = new EzAuth( $config ); // Instantiate a new `EzAuth` object, passing the configuration array as an argument.

3. Register Form:

Create a file named register_form.php containing the following HTML form. This form includes Bootstrap 5 for styling (you can replace it with your preferred framework).

<!-- register_form.php -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<form method="post">
	<?=$flash ?>
	<?=$csrfToken ?>
	
	<h1 class="my-3">Register Form</h1>
	<div class="mb-3 row">
		<label for="username" class="col-sm-3 col-form-label">Username:</label>
		<div class="col-sm-9">
			<input type="text" id="username" class="form-control" value="">
		</div>
	</div>
	<div class="mb-3 row">
		<label for="email" class="col-sm-3 col-form-label">Email:</label>
		<div class="col-sm-9">
			<input type="email" id="email" class="form-control" value="">
		</div>
	</div>
	<div class="mb-3 row">
		<label for="password" class="col-sm-3 col-form-label">Password:</label>
		<div class="col-sm-9">
			<input type="password" id="password" class="form-control">
		</div>
	</div>
	<div class="mb-3 row">
		<label for="confirm-password" class="col-sm-3 col-form-label">Confirm Password:</label>
		<div class="col-sm-9">
			<input type="password" id="confirm-password" class="form-control">
		</div>
	</div>
	<div class="mt-3 mb-3 row">
		<div class="col">
			<button type="submit" class="btn btn-primary float-end">Register</button>
		</div>
	</div>
</form>

4. register.php:

Create a file named register.php with the following code. It includes bootstrap.php and retrieves flash messages and the CSRF token from the EzAuth object before displaying the registration form.

// register.php
<?php
require_once 'bootstrap.php'; // Include bootstrap file

list(,$flash, $csrfToken ) = $auth->register();  // Extract flash message and CSRF token

include 'register_form.php';

You can now access register.php in your web browser to see the registration form and submit registration data. Good luck!

Reference

Configurations:

  • $config[ 'database' ]
  • $config[ 'email' ]
  • $config[ 'message' ]
  • $config[ 'auth' ]

Methods:

  • __construct( array $config )
  • $csrfToken = csrfToken()
  • $flash = flashMessage()
  • list( $status, $flash, $csrfToken ) = register( $callback = null )
  • list( $status, $flash ) = verifyEmail( $callback = null )
  • list( $status, $flash, $csrfToken ) = login( $callback = null )
  • list( $status, $flash, $csrfToken ) = recoverPassword( $callback = null )
  • list( $status, $flash, $csrfToken ) = resetPassword( $callback = null )
  • $user = memberArea( null|string|array $allowedRoles = null )
  • $user = isLoggedIn()
  • redirectLoggedInUser()
  • logout()

Simple Tutorial

Authors

@elmyrockers

License

MIT

elmyrockers/ezauth 适用场景与选型建议

elmyrockers/ezauth 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 06 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 elmyrockers/ezauth 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 elmyrockers/ezauth 我们能提供哪些服务?
定制开发 / 二次开发

基于 elmyrockers/ezauth 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 21
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-08