Project contains two parts:
Storage implementation. Located in a packagedirectory. Contains model classes for IPV4/6 addresses, storage interface, B-Tree driver interface.
B-Tree is implemented in a IpAddressBtree\Tree\FileSystemBtreeDriver class (file system storage). Linked to application as path repository.
app directory contains Symfony application which integrates package and provides CLI and RestAPI interfaces to storage.
git clone git@bitbucket.org:stas81/ip-store.git ./ip-store- clone projectcd ./ip-store/appcomposer install- install dependencies with Composer- check path to storage file in
app/config/papameters.ymlunderstorage_fileparameter
System supports both IPv4 and IPv6 addresses.
Implemented with two Symfony console commands, both takes one IP address as an argument:
bin/console app:address:query 195.154.2.10- display a number of times which IP address was added to the storagebin/console app:address:store 195.154.2.10- add IP address to the storage and display a number of times which IP address was added
- Query counter
- Request
GET /api/address?ip=195.154.2.10 - Response
{ "code": 200, "data": { "ip": "195.154.2.10", "type": "IPv4", "count": 2 } } - Request
- Store IP address
- Request
POST /api/address
{ "ip":"195.154.2.10" }- Response
{ "code": 201, "data": { "ip": "195.154.2.10", "type": "IPv4", "count": 3 } } - Request
Tests was made separately for package and app
- inside a
packagedirectory:composer install && vendor/bin/phpunit - in
appdirectoryvendor/bin/phpunit