PHP code example of yogcloud / framework

1. Go to this page and download the library: Download yogcloud/framework 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/ */

    

yogcloud / framework example snippets


composer 

$ php bin/hyperf
 fs
  fs:controller        Generate controller, Generated by default in app/Controller
  fs:model             Generate Model, default generate app/Model, Automatic generated Service,Interface
  fs:request           Generate request, Generated by default in app/Request
  fs:service           Generate service, Generated by default in app/Service
  fs:serviceInterface  Generate service interface, Generated by default in app/Service
server
    server:restart       Restart hyperf servers.
    server:start         Start hyperf servers.
    server:stop          Stop hyperf servers.

php bin/hyperf.php fs:model test

Model App\Model\Test was created.
success:[/demo/app/Rpc/TestServiceInterface.php]
success:[/demo/app/Service/TestService.php]

    /**
     * Query single entry - by ID.
     * @param int $id ID
     * @param array|string[] $columns Query field
     * @return array
     */
    public function getOneById(int $id, array $columns = ['*']): array;

    /**
     * Query single - according to the where condition.
     * @param array $where
     * @param array|string[] $columns
     * @param array Optional ['orderByRaw'=> 'id asc', 'with' = []]
     * @return array
     */
    public function findByWhere(array $where, array $columns=['*'], array $options = []): array;

    /**
     * Query multiple - by ID.
     * @param array $ids ID
     * @param array|string[] $columns
     * @return array
     */
    public function getAllById(array $ids, array $columns = ['*']): array;

    /**
     * Query multiple items according to where criteria.
     * @param array $where
     * @param array $columns
     * @param array  ['orderByRaw'=> 'id asc', 'with' = [], 'selectRaw' => 'count(*) as count']
     * @return array
     */
    public function getManyByWhere(array $where, array $columns = ['*'], array $options = []): array;

    /**
     * Multiple pages.
     * @param array $where
     * @param array|string[] $columns
     * @param array $options  ['orderByRaw'=> 'id asc', 'perPage' => 15, 'page' => null, 'pageName' => 'page']
     * @return array
     */
    public function getPageList(array $where, array $columns = ['*'], array $options = []): array;

    /**
     * Add single.
     * @param array $data
     * @return int
     */
    public function createOne(array $data): int;

    /**
     * Add multiple.
     * @param array $data
     * @return bool
     */
    public function createAll(array $data): bool;

    /**
     * Modify single entry - according to ID.
     * @param int $id id
     * @param array $data
     * @return int
     */
    public function updateOneById(int $id, array $data): int;

    /**
     * Modify multiple - according to ID.
     * @param array $where
     * @param array $data
     * @return int
     */
    public function updateByWhere(array $where, array $data): int;

    /**
     * Delete - Single.
     * @param int $id
     * @return int
     */
    public function deleteOne(int $id): int;

    /**
     * Delete - multiple.
     * @param array $ids
     * @return int
     */
    public function deleteAll(array $ids): int;

    /**
     * Handle native SQL operations.
     * @param mixed $raw
     * @param array $where
     * @return array
     */
    public function rawWhere($raw, array $where = []): array;

    /**
     * Get a single value
     * @param string $column
     * @param array $where
     * @return string
     */
    public function valueWhere(string $column, array $where): string;

composer dump-autoload -o

php bin/hyperf fs:model test --path plugin/demo/test/src

'selectRaw' => 'sum(`id`) as sum'

[function ($q) {
    $q->where('id', '=', 1)->orWhere('id', '=', 2);
}]