# phalcon

## Introduction

Phalcon in Tars

* Support Packing code
* Support Phalcon develop
* Support TarsConfig
* Support http & tars Protocol
* Limited by the design of the framework itself, it does not support cooperation

## Related

* tars-php-phalcon (<https://github.com/luoxiaojun1992/tars-php-phalcon>)
* Phalcon (<https://github.com/phalcon/cphalcon>)
* TARSPHP (<https://github.com/TarsPHP>)
* TARSPHP DOCKER (<https://github.com/tangramor/docker-tars>)

## Thanks

* [iamloso](https://github.com/iamloso)

## Project Directory Structure

* component: Common base class of Controller
* conf: The configuration required by the business
* controller: The C layer in the MVC model
* database: Database connection configuration
* libs: Common libs、server/model extensions、utils&#x20;
* models: The model file for the database table
* servant: Client code generated by tars2php, this directory name is completely customizable, just need to be distinguished when using them
* services: Business Logic Code
* tasks:  Console commands of business, for making debugging easier, can also be used as a timed task
* composer.json: Description of the project's dependencies
* index.php: The entrance of the service, the file name can be customized, but you must change the private template on the platform and add the field of entrance under the server
* services.php: Declare the base namespaceName of the entire project

## Use

1. Create project

   Clone code example

   ```
   git clone git@github.com:iamloso/tars-php-phalcon.git
   ```

   Install composer dependencies

   ```
   cd src && composer install -vvv
   ```
2. Basic service config

   Change `appName、serverName、objName` in tars/tars.proto.php
3. If you use the tasrsprotocol

   Write the tars interface description file in the tars directory，tars/tars.proto.php,add tarsFiles

   Executing compilation script in scripts directory to generate interface code

   ```
   /bin/bash tars2php.sh
   ```

   Create interface implementation class in src/services directory and write business logic code

   Edit services in src/services.php，replace interface and interface implementation namespace
4. Setting up the development environment of TarsPHP

   If using the HTTP protocol, refer to[TARS-PHP-HTTP Server and client development](https://tangramor.gitlab.io/tars-docker-guide/3.TARS-PHP-HTTP%E6%9C%8D%E5%8A%A1%E7%AB%AF%E4%B8%8E%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%BC%80%E5%8F%91/)

   If using the tars protocol, refer to[TARS-PHP-TCP Server and client development](https://tangramor.gitlab.io/tars-docker-guide/2.TARS-PHP-TCP%E6%9C%8D%E5%8A%A1%E7%AB%AF%E4%B8%8E%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%BC%80%E5%8F%91/)
5. Package the project in the tars PHP development environment(run `composer run-script deploy` in src)
6. Publish the project in the tars management background, please refer to [TARS-PHP-TCP Server and client development](https://tangramor.gitlab.io/tars-docker-guide/2.TARS-PHP-TCP%E6%9C%8D%E5%8A%A1%E7%AB%AF%E4%B8%8E%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%BC%80%E5%8F%91/))，test`curl 'http://{ip}:{port}/{api_route}'`
