Skip to content

Commit

Permalink
Updated version
Browse files Browse the repository at this point in the history
  • Loading branch information
eminetto committed May 15, 2012
1 parent da65c12 commit dd048fd
Show file tree
Hide file tree
Showing 27 changed files with 1,128 additions and 334 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
vendor/
_reports
*.bak
soa.log
*.DS_Store
.project
.classpath
uploads/
*sublime*
46 changes: 31 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
DEPRECATED
===========

Usar o README do projeto


Coderockr SOA Server
=========================

Expand All @@ -15,13 +21,13 @@ Instalation
----------

- Clone this project
- Execute vendor.sh to install dependencies (Linux and Mac for now)
- Execute vendors.sh to install dependencies (Linux and Mac for now)
- Create a virtual domain in Apache

---
<VirtualHost *:80>
DocumentRoot "/Users/eminetto/Documents/Projects/SOA-Server"
ServerName soa.local
ServerName soa.dev
<Directory "/Users/eminetto/Documents/Projects/SOA-Server">
Options Indexes Multiviews FollowSymLinks
AllowOverride All
Expand All @@ -42,27 +48,25 @@ Instalation

- Configure /etc/hosts:

127.0.0.1 soa.local
127.0.0.1 soa.dev


Rest
----

To be avaiable as a Rest service an entity must extend the model\Entity class. As an exemple, there is an User entity in this repository. To use it you must create the table, as the SQL below. The database configuration is in configs/configs.php file.

CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`login` varchar(10) DEFAULT NULL,
`password` varchar(10) DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`updated` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=65 DEFAULT CHARSET=latin1;
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`login` varchar(10) DEFAULT NULL,
`password` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
);

RPC
---

To be avaiable as a Rpc service a class must extend procedure\Procedure class, as shown in the procedure\Login.php sample.
To be avaiable as a Rpc service a class must extend service\Service class, as shown in the service\Login.php sample.

Authorization
-----------
Expand All @@ -74,6 +78,18 @@ How to access

Urls:

http://soa.local/user/1 - show user with id = 1
http://soa.local/users - show all users
http://soa.local/sample - the sample.html file shows how to use the services using Javascript
http://soa.dev/user/1 - show user with id = 1
http://soa.dev/users - show all users
http://soa.dev/sample - the sample.html file shows how to use the services using Javascript


#Geração das tabelas

Para que o Doctrine gere as tabelas no banco de dados baseado nas entidades:

cd Backend/SOA-Server
APPLICATION_ENV=development php ./bin/doctrine.php orm:schema-tool:create
APPLICATION_ENV=testing php ./bin/doctrine.php orm:schema-tool:create

Desta forma são criadas as tabelas na base de desenvolvimento e na de testes

4 changes: 4 additions & 0 deletions bin/doctrine
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env php
<?php

include('doctrine.php');
38 changes: 38 additions & 0 deletions bin/doctrine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

include __DIR__.'/../bootstrap.php';

$helpers = array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
);

$cli = new \Symfony\Component\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
$cli->setCatchExceptions(true);
$helperSet = $cli->getHelperSet();
foreach ($helpers as $name => $helper) {
$helperSet->set($helper, $name);
}
$cli->addCommands(array(
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),

// ORM Commands
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand(),

));
$cli->run();
106 changes: 106 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
use Silex\Provider\DoctrineServiceProvider;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Silex\Provider\ValidatorServiceProvider;
use Symfony\Component\ClassLoader\UniversalClassLoader;


use Doctrine\ORM\Tools\Setup,
Doctrine\ORM\EntityManager,
Doctrine\Common\EventManager as EventManager,
Doctrine\ORM\Events,
Doctrine\ORM\Configuration,
Doctrine\Common\Cache\ArrayCache as Cache,
Doctrine\Common\Annotations\AnnotationRegistry,
Doctrine\Common\ClassLoader;

require_once __DIR__.'/vendor/silex.phar';

require_once __DIR__.'/vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php';

$classLoaderSymfony = new \Doctrine\Common\ClassLoader('Symfony', __DIR__.'/vendor' );
$classLoaderSymfony->register();

$classLoaderDoctrineCommon = new \Doctrine\Common\ClassLoader('Doctrine\\Common', __DIR__.'/vendor/doctrine/common/lib' );
$classLoaderDoctrineCommon->register();

$classLoaderDoctrineMigrations = new \Doctrine\Common\ClassLoader('Doctrine\\DBAL\\Migrations', __DIR__.'/vendor/doctrine/dbal/lib' );
$classLoaderDoctrineMigrations->register();

$classLoaderDoctrineDbal = new \Doctrine\Common\ClassLoader('Doctrine\\DBAL', __DIR__.'/vendor/doctrine/dbal/lib' );
$classLoaderDoctrineDbal->register();

$classLoaderDoctrine = new \Doctrine\Common\ClassLoader('Doctrine', __DIR__.'/vendor/doctrine/orm/lib' );
$classLoaderDoctrine->register();

$classLoaderJMS = new \Doctrine\Common\ClassLoader('JMS', __DIR__.'/vendor' );
$classLoaderJMS->register();

$classLoaderDMS = new \Doctrine\Common\ClassLoader('DMS', __DIR__.'/vendor' );
$classLoaderDMS->register();

$classLoaderMetadata = new \Doctrine\Common\ClassLoader('Metadata', __DIR__.'/vendor/Metadata/src' );
$classLoaderMetadata->register();

$classLoaderModel = new \Doctrine\Common\ClassLoader('model', __DIR__ );
$classLoaderModel->register();

$classLoaderService = new \Doctrine\Common\ClassLoader('service', __DIR__ );
$classLoaderService->register();

$classLoaderTest = new \Doctrine\Common\ClassLoader('test', __DIR__ );
$classLoaderTest->register();

$classLoaderCoderockr = new \Doctrine\Common\ClassLoader('Coderockr', __DIR__.'/vendor' );
$classLoaderCoderockr->register();

if(!getenv('APPLICATION_ENV'))
$env = 'testing';
else
$env = getenv('APPLICATION_ENV');

if ($env == 'testing')
include __DIR__.'/configs/configs.testing.php';
elseif ($env == 'development')
include __DIR__.'/configs/configs.development.php';
else
include __DIR__.'/configs/configs.php';

include __DIR__.'/library/filter.php';

//doctrine
$config = new Configuration();
$cache = new Cache();
$config->setQueryCacheImpl($cache);
$config->setProxyDir('/tmp');
$config->setProxyNamespace('EntityProxy');
$config->setAutoGenerateProxyClasses(true);

//mapping (example uses annotations, could be any of XML/YAML or plain PHP)
AnnotationRegistry::registerFile(__DIR__.'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
AnnotationRegistry::registerAutoloadNamespace('JMS', __DIR__.'/vendor');

$driver = new Doctrine\ORM\Mapping\Driver\AnnotationDriver(
new Doctrine\Common\Annotations\AnnotationReader(),
array(__DIR__ .'/model')
);
$config->setMetadataDriverImpl($driver);
$config->setMetadataCacheImpl($cache);

//getting the EntityManager
$em = EntityManager::create(
$dbOptions,
$config
);


//load subscribers
$evm = $em->getEventManager();
$directoryIterator = new \DirectoryIterator(__DIR__ . '/model/subscriber');
foreach ($directoryIterator as $f) {
if ($f->getFileName() != '.' && $f->getFilename() !='..') {
$subscriber = 'model\\subscriber\\' . $f->getBasename('.php');
$evm->addEventSubscriber(new $subscriber);
}
}
4 changes: 2 additions & 2 deletions configs/clients.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$clients = array(
'85e4a615f62c711d3aac0e7def5b4903' => 'Coderockr App 1',
'85e4a615f62c71sdfdsfds1d3aac0e7def5b4903' => 'Coderockr App 2',
'85e4a615f62c711d3aac0e7def5b4903' => 'Test Suite',
'85e4a615f62c71sdfdsfds1d3aac0e7def5b4903' => 'Admin Interface',
);
11 changes: 11 additions & 0 deletions configs/configs.development.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
$dbOptions = array(
'driver' => 'pdo_mysql',
'host' => 'soatest.dev',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => '48pratos',
);

$soaUrl = 'http://soatest.dev:8080';
13 changes: 8 additions & 5 deletions configs/configs.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
$dbOptions = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'dbname' => 'rest',
);
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => '',
'dbname' => '48pratos',
);

$soaUrl = 'http://soa.dev';
11 changes: 11 additions & 0 deletions configs/configs.testing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
$dbOptions = array(
'driver' => 'pdo_mysql',
'host' => 'soatest.dev',
'port' => '3306',
'user' => 'root',
'password' => '',
'dbname' => '48pratos_test',
);

$soaUrl = 'http://soatest.dev:8080';
Binary file added favicon.ico
Binary file not shown.
Loading

0 comments on commit dd048fd

Please sign in to comment.