Download the PHP package dersonsena/yii2-app-restapi without Composer

On this page you can find all versions of the php package dersonsena/yii2-app-restapi. 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 yii2-app-restapi

Yii 2 API Rest Project Template


Yii 2 API Rest Project Template is a skeleton Yii 2 application best for rapidly creating API Rest projects.

DIRECTORY STRUCTURE

The directory structure is similar to the Basic template added in the Advanced feature, which is the generation of the *-local.php, web/index.php files, and the yii script according to your environment

  + assets/             contains assets definition
  + components/         containes the application components
  + commands/           contains console commands (controllers)
  - config/             contains application configurations
    * routes/           contains the routes configurations files
  + environments        contains environments templates files (see the advanced template)
  + mail/               contains view files for e-mails
  + migrations/         contains the migrations scripts
  + models/             contains model classes
  + modules/            contains de application modules
  + runtime/            contains files generated during runtime
  + tests/              contains various tests for the basic application
  + vendor/             contains dependent 3rd-party packages
  + web/                contains the entry script and Web resources

REQUIREMENTS

The minimum requirement by this project template that your Web server supports PHP 5.4.0.

INSTALLATION

Install via Composer

If you do not have Composer, you may install it by following the instructions at getcomposer.org.

You can then install this project template using the following command:

php composer create-project --stability=dev dersonsena/yii2-app-restapi

Now you should be able to access the application through the following URL, assuming basic is the directory directly under the Web root.

http://localhost/basic/web/

Install with Docker

Update your vendor packages

docker-compose run --rm php composer update --prefer-dist

Run the installation triggers (creating cookie validation code)

docker-compose run --rm php composer install

Start the container

docker-compose up -d

You can then access the application through the following URL:

http://127.0.0.1:8000

See more details in: https://hub.docker.com/_/mysql

NOTES:

CONFIGURATION

Environment Files

Just like in the Advanced template, to generate the files according to your work environment you need to execute the init script and then choose your environment: Development or Production

This script will create the files:

  /yii
  /web/index.php
  /config/console-local.php
  /config/web-local.php

NOTES:

See more details for use in the Advanced template documentation.

Database

Edit the file config/web-local.php with real data, for example:

NOTES:

Migration

Run the migration script to create the users table with the following command:

The User.php model has already been generated by the GII, but a few things have been added. To access it, simply open the models/User.php file

NOTES:

All models MUST extend the app\components\ModelBase class. See it for more implementation details.

API Routes

All your API routes must be within config/routes. The following code is the already configured route of users:

Accessing Users Web Service

To access the list of users through your REST API, simply access the address below in your browser or in external applications such as Postman:

When accessing this address you should see a list with only one user similar to JSON below:

See more details in RESTful Web Services Guide.

Authentication

The authentication used is HttpBearerAuth, where a Token with JWT is passed for user authentication in its API. Initially it is inactive. To activate it is quite simple, just go in the app\components\BaseController class and uncomment the lines:

When uncommenting these lines and trying to rerun the list of users, you should return a message as below:

NOTES: If you want some action to be open, that is, do not authenticate to the API, just add inside the $excepts array.

For more details on REST authentication with Yii, see the Official Framework Documentation.


All versions of yii2-app-restapi with dependencies

PHP Build Version
Package Version
Requires php Version >=7
ext-intl Version *
ext-mbstring Version *
yiisoft/yii2 Version ~2.0.14
yiisoft/yii2-swiftmailer Version ~2.0.0
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 dersonsena/yii2-app-restapi contains the following files

Loading the files please wait ....