Re: Dealing with big cakephp applications

2013-07-29 Thread Karey Powell
Hello Diogo,

So, it seems to me that you need to create a Service Oriented Architecture 
(SOA) in order to facilitate seamless communication for these three 
different 
modules (User and Permission management, Projects, and Financing) kind of 
like what Amazon did and I would also be looking into creating that app as 
a Multi-Tenant application. That way, you can point each main part of the 
app to a sub-domain, but maintain only a single copy of that application, 
which in 
turn sort of brings down the complexity level a bit for testing. Turning 
your application into a Software as a Service (SaaS) can prove to be 
beneficial, but on 
the flip side it may not be what you want, so be sure to research the pros 
and cons to see how best it fits your needs.

The next important thing that you should consider is how your storing the 
data, meaning if you want to go with a relational database or a No-SQL 
datastore. I 
assume that you are already using a relational database, so migrating to 
something else at this time will be tremendous work given the size of the 
app now. 
For example, PostgreSQL a popular opensource RDBMS allows you to store 
schema-less data using 
Hstore. 
You could for example, define scopes 
to limit or restrict certain data and fields based on which sub-domain your 
on.

Also, as Reuben suggested, try to find those parts of the current app that 
intersects and build them out into a plugin, so you can share them across 
domains 
and when you add a new feature(s) or re-factor some existing feature(s) all 
the apps gets updated, given that composer is what you are using to manage 
these 
packages; nonetheless, it shouldn't be a problem updating features.

In the end, there are many ways you could go about doing this, but I 
suggest that you look into SOA and Multi-Tenant applications. Here is a 
small case 
study on Multi-tenancy with 
CakePHP. 
I hope this helps to get you started.

On Monday, 29 July 2013 12:48:48 UTC-4, Diogo FC Patrao wrote:
>
> Hello
>
> In my company, we develop software with cakephp for internal usage. The 
> software is getting big for managing it as a single project (46 
> controllers, 94 models), and we've been thinking about splitting it in two 
> or three different software, each to manage one different domain of the big 
> picture (like, a system for user and permission management, other for 
> projects, other for financing).
>
> However, there is the need for those modules keep comunicating. For 
> instance, a report will need to get for all projects belonging to user X 
> the current balance - That would need at least three models in three 
> different modules. If I would be working with three different and 
> independent cakephp, either I need to (1) get a copy of models from the 
> other software, or (2) communicate via webservices.
>
> (1) is faster, however, I'll have a huge number of models anyway. Not to 
> mention, as business rules are in the models, when one is updated, it must 
> be copied to the other systems, causing a maintenance nightmare.
>
> (2) is ideal as it really encapsulate responsabilities, however it is 
> slow. For instance, if I make a find on model Projects, each having a list 
> of people linked to it, I'd like to bind those models. As far as I know, 
> there's no Webservice Datasource, so I'll need to do it by hand.
>
> I'd rather (3) have everything deployed in one big cakephp installation, 
> but maintain my repositories apart; however it would difficult testing. But 
> I guess that, when working with big problems like that, you really have to 
> face some difficulties.
>
> What are your thoughts on that problem?
>
> Thanks!
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Dealing with big cakephp applications

2013-07-29 Thread Reuben
I might suggest usage of plugins, and perhaps composer.

I'm not sure if you're talking about physical domains, when it comes to the 
split (as in there's one URL for users and permissions, another for 
projects and another for financing).  Lets assume you do, and address the 
alternative later on.

So, with three domains, that's possibly 3 applications, and those 
applications just include the plugins that are relevant for the app to run. 
 Some apps may share the same plugin, so use composer to source the plugins 
from a single location.  There's a fair bit of refactoring in there, so 
you'd want to think about it very carefully.

Now, the alternative, it's still the single domain, but you just want to 
split the source up.  I'd still suggest plugins.  Find a handful of 
controllers and models that work tightly together and isolate them in their 
own plugin. Conceivably, you could drop that plugin to any other project 
and use it.  There may be a dependency tree on other plugins.  And you 
could still use composer to help manage including specific versions of the 
plugins into the single app.

I'd be excited to consider usage of namespaces to aid with the split.  It's 
not something that I've dived into yet with PHP, and I'll be waiting until 
CakePHP 3.0 before I do.

Not sure what you're using for source control, but I'd shy away from git 
submodules. For the few dealings that I've had with them, they seem to 
introduce more problems that they're worth.

My 2c on large systems with shared components.

Regards
Reuben Helms

On Tuesday, 30 July 2013 02:48:48 UTC+10, Diogo FC Patrao wrote:
>
> Hello
>
> In my company, we develop software with cakephp for internal usage. The 
> software is getting big for managing it as a single project (46 
> controllers, 94 models), and we've been thinking about splitting it in two 
> or three different software, each to manage one different domain of the big 
> picture (like, a system for user and permission management, other for 
> projects, other for financing).
>
> However, there is the need for those modules keep comunicating. For 
> instance, a report will need to get for all projects belonging to user X 
> the current balance - That would need at least three models in three 
> different modules. If I would be working with three different and 
> independent cakephp, either I need to (1) get a copy of models from the 
> other software, or (2) communicate via webservices.
>
> (1) is faster, however, I'll have a huge number of models anyway. Not to 
> mention, as business rules are in the models, when one is updated, it must 
> be copied to the other systems, causing a maintenance nightmare.
>
> (2) is ideal as it really encapsulate responsabilities, however it is 
> slow. For instance, if I make a find on model Projects, each having a list 
> of people linked to it, I'd like to bind those models. As far as I know, 
> there's no Webservice Datasource, so I'll need to do it by hand.
>
> I'd rather (3) have everything deployed in one big cakephp installation, 
> but maintain my repositories apart; however it would difficult testing. But 
> I guess that, when working with big problems like that, you really have to 
> face some difficulties.
>
> What are your thoughts on that problem?
>
> Thanks!
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Dealing with big cakephp applications

2013-07-29 Thread Diogo FC Patrao
Hello

In my company, we develop software with cakephp for internal usage. The 
software is getting big for managing it as a single project (46 
controllers, 94 models), and we've been thinking about splitting it in two 
or three different software, each to manage one different domain of the big 
picture (like, a system for user and permission management, other for 
projects, other for financing).

However, there is the need for those modules keep comunicating. For 
instance, a report will need to get for all projects belonging to user X 
the current balance - That would need at least three models in three 
different modules. If I would be working with three different and 
independent cakephp, either I need to (1) get a copy of models from the 
other software, or (2) communicate via webservices.

(1) is faster, however, I'll have a huge number of models anyway. Not to 
mention, as business rules are in the models, when one is updated, it must 
be copied to the other systems, causing a maintenance nightmare.

(2) is ideal as it really encapsulate responsabilities, however it is slow. 
For instance, if I make a find on model Projects, each having a list of 
people linked to it, I'd like to bind those models. As far as I know, 
there's no Webservice Datasource, so I'll need to do it by hand.

I'd rather (3) have everything deployed in one big cakephp installation, 
but maintain my repositories apart; however it would difficult testing. But 
I guess that, when working with big problems like that, you really have to 
face some difficulties.

What are your thoughts on that problem?

Thanks!

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Model HABTM Model Referencing Original Model

2013-07-29 Thread Benjam Welker
This is a duplicate of my question asked on StackOverflow here: 
http://stackoverflow.com/questions/17875143/model-habtm-model-referencing-original-model
If you could answer the question there, or let me know if it is a bug or 
not, it would be greatly appreciated.

I have a Team model that is HABTM Match and when I pull the data for a 
specific Team, I ask for the related Teams for those Matches, but Cake only 
returns the data for the original Team.

How can I get all the Teams (the opponent) for that Match without looping 
through the results and pulling them that way?

I am having the same issue with the Team HABTM Player association as well. 
 When I pull a Player, Cake will not return any of the associated Players 
(teammates) for the linked Team.

*My schema:*

CREATE TABLE IF NOT EXISTS `matches` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `tournament_id` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL DEFAULT '',
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `tournament_id` (`tournament_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;


CREATE TABLE IF NOT EXISTS `matches_teams` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `match_id` int(10) unsigned NOT NULL,
  `team_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `match_id` (`match_id`,`team_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;


CREATE TABLE IF NOT EXISTS `players` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;


CREATE TABLE IF NOT EXISTS `players_teams` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `player_id` int(10) unsigned NOT NULL,
  `team_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `player_id` (`player_id`,`team_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;


CREATE TABLE IF NOT EXISTS `teams` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `tournament_id` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `seed` smallint(2) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `tournament_id` (`tournament_id`),
  KEY `seed` (`seed`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

*My query:*

$this->Team->recursive = 3;
$team = $this->Team->read(null, $id);
$this->set('team', $team);

*I have also tried:*

$this->Team->contain(array(
'Match' => array(
'Team',
),
));
$team = $this->Team->read(null, $id);
$this->set('team', $team);

*The results (`$team`):*

array (size=4)
  'Team' => 
array (size=5)
  ... team data ...

  'Match' => 
array (size=2)
  0 => 
array (size=9)
  ... match data ...
  
  'MatchesTeam' => 
array (size=3)
  'id' => string '1' (length=1)
  'match_id' => string '1' (length=1)
  'team_id' => string '1' (length=1)

// there should be an array for 'Team' here
// that contains the opponent team

  1 => 
... more match data with same missing 'Team' array ...

... other related models ...

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Cache Help

2013-07-29 Thread jmn2k1
You must "invalidate" the cache, ie, delete the cache in a onSave callback.

On Friday, July 26, 2013 9:05:30 PM UTC-3, advantage+ wrote:
>
> Maybe I was reading wrong but I was under the impression if you cache an 
> object (find data) if it was different it would delete the original cached 
> data.
>
>  
>
> I am caching the results of a find, but as admin if I edit the record the 
> cached data is always returned not the new data.
>
>  
>
> Is ther a way to fetch new data after save and delete cached info?
>
>  
>
> *Dave Maharaj*
>
> *Freelance Designer | Developer*
> [image: Description: header_logo]
> www.movepixels.com  |  d...@movepixels.com   |  709.800.0852
>
>  
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Issue Update() function in MSSQLfor CakePHP

2013-07-29 Thread GS
Hi,

I am new to CakePHP but worked extensively in C++/C/Java etc. I already 
spend more than a day but could not figure out what is the reason for the 
following problem.

I am using latest XAMP version with 5.4.16 PHP, Apache 2.4.4. We have 
developed a small client on CakePHP with MYSQL DB. Its working fine. We 
already has similar DB in MSSQL. Now we need to run this client with MSSQL.

We are using php_pdo_sqlsrv_54_ts.dll and php_sqlsrv_54_ts.dll for MSSQL 
driver for this.

Whenever we are updating values in tables, we are using following 
UpdateAll() of Model.PHP which further calls update() of datasource as

$this->Configurationtable->updateAll(('Configurationtable.configuration_optionsetting'
 
=>  $limit ), array('Configurationtable.configuration_optionname =' => 
$optionName)))

Where $limit and $optionName has value values. This work work in MYSQL and 
generates 

UPDATE `dbname`.`configurationtable` AS `Configurationtable` SET 
`Configurationtable`.`configuration_optionsetting` = 12 WHERE 
`Configurationtable`.`configuration_optionname` = 'searchPaginationLimit'

But in MSSQL, it fails and generate something completely different like this
SELECT [Configurationtable].[id] AS [Configurationtable__id] FROM 
[configurationtable] AS [Configurationtable] WHERE 
[Configurationtable].[configuration_optionname] = N'searchPaginationLimit'

Now, if  I modify the update() function in 
\Cake\Model\Datasource\Database\Sqlserver.php and make it similar to 
update() function in \Cake\Model\Datasource\Database\Mysql.php, then it 
works absolutely fine and generate a proper "Update" Query in MSSQL also?

I could not figure out WHY? Is it something I am doing wrong OR is there a 
bug in Cake?

Can you please help me.

Cheers

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




I have a large CakePHP app and need to support iOS and Android

2013-07-29 Thread PatR
I have a large CakePHP app (well over 100K lines of php, many languages, 
over 2 million users) and I need to support iOS and Android clients. I 
would like to put all the data and business logic in a "back end" that is 
shared across all 3 clients. I know a major rewrite is needed and I am 
looking for recommendations on architecture. I am thinking of moving to a 
"Service Oriented Architecture", putting all the data and business logic in 
"backend services" with defined interfaces that can be used by the CakePHP, 
iOS and Android clients. 

Some considerations:

   1. Ease/Speed of adding new features across all clients is critical. I 
   would like to add functionality to the backend and enable the clients all 
   to use it with all the code in the backend being shared and all the code in 
   the clients being specific to the needs of that client.
   2. I would like to use open-source components (not Cake components) 
   where possible in the backend. They need to be production tested and 
   currently supported by an active community. I would like to use 
   standards-based interfaces and protocols where possible to make it easier 
   to use open-source components. 
   3. I would like the interfaces to support multiple versions at the same 
   time so I can upgrade components independently. 
   4. I would like to have a consistent security model shared across the 
   interface.

Are there some 'recommended best practices' for this?
Are there some frameworks that will make this easier?

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.




Issue with Update function in sql server in CakePHP, not working

2013-07-29 Thread GS
Hi,

We have a client in CakePHP running with MYSQL. PHP version is 5.4.16, 
Apache 2.4.4, latest XAMP.

THis running is working fine. We already have similar Database in MSSQL 
also. Now client wants to run this client with MSSQL also.

We are using php_pdo_sqlsrv_54_ts.dll and php_sqlsrv_54_ts.dll for MSSQL 
driver for this. Its sql server 2005.

Whenever we are updating values in tables, we are using following 
UpdateAll() of Model.PHP which further calls update() of data source as 

$this->Configurationtable->updateAll(array('Configurationtable.configuration
_optionsetting' =>  $limit ),
array('Configurationtable.configuration_optionname =' => $optionName))

Now this works fine in MySql and generated the following Update query
UPDATE `ipa`.`configurationtable` AS `Configurationtable` SET 
`Configurationtable`.`configuration_optionsetting` = 12 WHERE 
`Configurationtable`.`configuration_optionname` = 'searchPaginationLimit'

But in MSSQL Server, it fails and generates completely wrong query which is

SELECT [Configurationtable].[id] AS [Configurationtable__id] FROM 
[configurationtable] AS [Configurationtable] WHERE 
[Configurationtable].[configuration_optionname] = N'searchPaginationLimit'

Now, If I make Update() function in \lib\Cake\Model\Datasource\Database\
Sqlserver.php similar to Update() in 
\lib\Cake\Model\Datasource\Database\Mysql.php 
then it works fine. It generates proper correct "Update" query
I could not figure out why is it going so? Is it something I am going wrong 
OR there is bug in cake?
Any would be of great help.
Cheers

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.