aacassandra/parsequent
Composer 安装命令:
composer require aacassandra/parsequent
包简介
Save your time with Parsequent, for CRUD your laravel project using parse rest api
README 文档
README
Parse Eloquent
This is a package for laravel framework especially for CRUD activities. This package uses the eloquent laravel style and doesn't leave the default eloquent style. It's just that this package makes it easier for us to perform CRUD activities without including the model dependency on the associated controller.
Suported Features
- Create
- Read
- Update
- Delete
- Batch
- CountingObjects
- SignIn
- SignOut
- VerifyingEmails
- PasswordReset
- ValidatingSessionTokens
- CreateUser
- With Role [Optional]
- ReadUser
- UpdateUser
- With Role [Optional]
- DeleteUser
- CreateRole
- ReadRole
- UpdateRole
- DeleteRole
Installation in Laravel
This package can be used with Laravel 5 or higher.
-
This package publishes a config/parsequent.php file. If you already have a file by that name, you must rename or remove it.
-
You can install the package via composer:
composer require aacassandra/parsequent
- In the $providers array add the service providers in your config/app.php file:
'providers' => [
/*
* Package Service Providers
*/
// ...
Parsequent\ParseProvider::class,
];
- Add the facade of this package to the $aliases array.
'aliases' => [
// ...
'Parse' => Parsequent\Parse::class,
]
- You must publish the config. which will later be on the config/parsequent.php config file with:
php artisan vendor:publish --provider="Parsequent\ParseProvider"
- Now the Parse Class will be auto-loaded by Laravel.
Object Format
| No | Method | Parameters | Options |
|---|---|---|---|
| 1 | Create | className [string], data [array], options [array] | masterKey [bool] |
| 2 | Read | className ['string], options [array] | objectId [string] where [array] orWhere [array] limit [int] skip [int] order [string] keys [array] include [array] relation [string] masterKey [bool] |
| 3 | Update | className [string], data [array], options [array] | objectId [string] where [array] orWhere [array] masterKey [bool] |
| 4 | Delete | className [string] , options [array] | objectId [string] where [array] orWhere [array] masterKey [bool] |
Example
1. Create
To create a new object in Parse. You can follow an example as described below:
<?php
namespace App\Http\Controllers;
use Parsequent\Parse;
class DevController extends Controller
{
public function dev(Request $request)
{
$create = Parse::Create('GameScore', [
'score' => 1337,
'playerName' => 'Sean Plott',
'cheatMode' => false
]);
if($create->status){
// handling success
}else{
// handling error
}
}
}
The response body is a JSON object containing the objectId and the createdAt timestamp of the newly-created object:
{
"output": {
"createdAt": "2011-08-20T02:06:57.931Z",
"objectId": "Ed1nuqPvcm"
},
"code": 201,
"status": true
}
2. Read
After you create an object, you can retrieve its content by calling a method. For example, to retrieve the object we created above:
<?php
namespace App\Http\Controllers;
use Parsequent\Parse;
class DevController extends Controller
{
public function dev(Request $request)
{
$read = Parse::Read('GameScore', [
'objectId' => 'Ed1nuqPvcm'
]);
if($read->status){
// handling success
}else{
// handling error
}
}
}
The response body is a JSON object containing all the user-provided fields, plus the createdAt, updatedAt, and objectId fields:
{
"output": {
"score": 1337,
"playerName": "Sean Plott",
"cheatMode": false,
"skills": [
"pwnage",
"flying"
],
"createdAt": "2011-08-20T02:06:57.931Z",
"updatedAt": "2011-08-20T02:06:57.931Z",
"objectId": "Ed1nuqPvcm"
},
"code": 200,
"status": true
}
3. Update
To change the data on an object that already exists, calling method Parse::Update. Any keys you don’t specify will remain unchanged, so you can update just a subset of the object’s data. For example, if we wanted to change the score field on a specific object:
<?php
namespace App\Http\Controllers;
use Parsequent\Parse;
class DevController extends Controller
{
public function dev(Request $request)
{
$update = Parse::Update('GameScore', [
'score' => 73453
], [
'objectId' => 'Ed1nuqPvcm'
]);
if($update->status){
// handling success
}else{
// handling error
}
}
}
The response body is a JSON object containing just an updatedAt field with the timestamp of the update.
{
"output": {
"updatedAt": "2011-08-21T18:02:52.248Z"
},
"code": 200,
"status": true
}
If you want to change multiple lines with conditionals, add a where / orwhere parameter in the options. here we will run 'Batch', to update multiple rows at once.
<?php
namespace App\Http\Controllers;
use Parsequent\Parse;
class DevController extends Controller
{
public function dev(Request $request)
{
$update = Parse::Update('GameScore', [
'score' => 73453
], [
'where' => [
['cheatMode', 'equalTo', false]
]
]);
if($update->status){
// handling success
}else{
// handling error
}
}
}
Because to update multiple rows at once we use 'Batch', as explained on the official page. The response from batch will be a list with the same number of elements as the input list. Each item in the list with be a dictionary with either the success or error field set. The value of success will be the normal response to the equivalent REST command:
{
"output": [
[
"succes": [
"updatedAt": "2020-12-10T08:04:47.256Z"
]
],
...
],
"code": 200,
"status": true
}
4. Delete
To delete an object from Parse Cloud, you can use the Parse::Delete method. Same as the update object method. You can delete a single object or multiple objects at once. To delete a single object, look at the example below:
<?php
namespace App\Http\Controllers;
use Parsequent\Parse;
class DevController extends Controller
{
public function dev(Request $request)
{
$delete = Parse::Delete('GameScore', [
'objectId' => 'Ed1nuqPvcm'
]);
if($delete->status){
// handling success
}else{
// handling error
}
}
}
The response body is a JSON object containing all the user-provided fields, plus the createdAt, updatedAt, and objectId fields:
{
"output": {},
"code": 200,
"status": true
}
Whereas to delete multiple objects at once, you can do it like this:
<?php
namespace App\Http\Controllers;
use Parsequent\Parse;
class DevController extends Controller
{
public function dev(Request $request)
{
$delete = Parse::Delete('GameScore', [
'where' => [
['cheatMode', 'equalTo', true]
]
]);
if($delete->status){
// handling success
}else{
// handling error
}
}
}
And then the response will be like this
{
"output": [
[
"succes": {}
],
...
],
"code": 200,
"status": true
}
License
This project is licensed under the MIT License - see the LICENSE.md file for details
aacassandra/parsequent 适用场景与选型建议
aacassandra/parsequent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 12 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sdk」 「parse」 「laravel」 「eloquent」 「parse-sdk」 「Laravel Parse」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aacassandra/parsequent 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aacassandra/parsequent 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aacassandra/parsequent 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
yii2 xml request parser
Parse promotion arrays from the Wayne State University API
Parse use statements for a reflection object
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Parse verse textual representation into book/chapter/verse ranges
Bureaux A Partager Edit - Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
统计信息
- 总下载量: 43
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-06
