PHPackages                             ngthuc/ci-composer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. ngthuc/ci-composer

ActiveProject

ngthuc/ci-composer
==================

The CodeIgniter framework with composer, include REST server

3.1.0(5y ago)013MITPHPPHP &gt;=5.6

Since Nov 29Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ngthucdotcom/ci-composer)[ Packagist](https://packagist.org/packages/ngthuc/ci-composer)[ Docs](https://ngthucdotcom.github.io/ci-composer/)[ RSS](/packages/ngthuc-ci-composer/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (3)Versions (29)Used By (0)

Server Requirements
===================

[](#server-requirements)

- OS: Linux 18.04 (recommended)
- PHP: PHP 5.6 or newer

Installation
============

[](#installation)

Create project
--------------

[](#create-project)

1. Run composer create project (for init new project) or update (for reload dependencies on new environment) via command line at root folder

- Create project

```
composer create-project ngthuc/ci-composer
```

- Reload dependencies

```
composer update
```

2. Create .env file same \[.\]env to set-up database

Require project into another project
------------------------------------

[](#require-project-into-another-project)

1. Run composer require project (for init new project) or update (for reload dependencies on new environment) via command line at root folder

- Require project

```
composer require ngthuc/ci-composer
```

- Reload dependencies

```
composer update
```

2. Move all files from `/vendor/ngthuc/ci-composer/app/` to the root folder structure:

```
root                          # → Root Directory
└── vendor/
    └── ngthuc/
        └── ci-composer/
            └── app/
                ├── apllication/
                ├── public/
                ├── .bowerrc
                ├── .editorconfig
                ├── .gitignore
                ├── .htaccess
                ├── [.]env
                ├── bower.json
                ├── index.php
                └── license.txt
```

3. Create .env file same \[.\]env to set-up database

Usage
=====

[](#usage)

- Use Apache - MySQL/MariaDB - PHP (AMP) stack as a software (e.g., [XAMPP](https://www.apachefriends.org/index.html)/[AMPPS](https://www.ampps.com/)/[WAMP](http://www.wampserver.com/en/))
- Install AMP stack packages on Linux or Windows, and move project to root directory of Apache (e.g., `www/`) and use [built-in web server](https://www.php.net/manual/en/features.commandline.webserver.php) (with PHP 5.4.0 or newer) via command:

```
php -S : -t
# Example use this command on root directory
php -S localhost:8000
```

Usage RestAPI
-------------

[](#usage-restapi)

CodeIgniter Rest Server is available on package.

Step 1: Add this to your controller (should be before any of your code)

```
use chriskacerguis\RestServer\RestController;
```

Step 2: Extend your controller

```
class Example extends RestController
```

Basic GET example

Here is a basic example. This controller, which should be saved as `Api.php`, can be called in two ways:

- `http://domain/api/users/` will return the list of all users
- `http://domain/api/users/id/1` will only return information about the user with id = 1

```
