Paul Oscher

Paul Oscher



but I think that the rock star you've gotta be able to see from a distance.

Nick Cave - 20,000th day on the planet Earth

Zend Framework 2 – Database access pattern

TableGateway-ről, de akár, a Zend Framework 2 -ről : Yes, for small projects it can be, or seem like, overkill. But as project complexity grows, as it invariably does, you won’t miss the time not spent maintaining your application.

TableGateway ,RowGateway https://leanpub.com/using-zend-framework-2/read

Feature
ZF2
Symfony 2
Cake PHP
CodeIgniter
Yii
Current version
2.2.1
2.3.1
2.3.6
2.1.3
1.1.13
Distribution
3 Mb
4.4 Mb
2.0 Mb
2.2 Mb
3.9 Mb
archive size
Installation
Composer
Composer
Archive
Archive
Archive
Compatibility
Bad (requires
Bad (requires
Good
Good
Good
with
SSH and
SSH and
shared hostings
vhosts)
vhosts)
Monolithic or
Components
Components
Components
Components
Monolithic
component-
based?
Prefer
Configuration
Configuration
Conventions
Conventions
Conventions
conventions
or configs?
Database access
Data Mapper
Data Mapper
Active Record
Traditional
Active Record,
pattern
(Doctrine/ORM),
(Doctrine/ORM)
or
PDO
Table Gateway,
Active Record
Row Gateway
Database
Yes (Doctrine-
Yes (Doctrine-
Yes
Yes
Yes
migrations
provided)
provided)
CSS Framework
Twitter
Twitter
Any
Any
Blueprint CSS
Bootstrap
Bootstrap
View Template
Any you want, or
Twig
Smarty/Twig
Any you want,
None or Prado
Language
none at all
(recommended)
or none
Unit testing
Yes (PHPUnit)
Yes (PHPUnit)
Yes (PHPUnit)
Yes (PHPUnit)
Yes (PHPUnit-
support
based)
Functional
Yes (PHPUnit)
Yes (PHPUnit)
Yes
No
Yes (Selenium)
testing
Database
Yes (Doctrine-
Yes (Doctrine
Yes
No
Yes
fixtures
provided)
bundle)

ZendDbTableGateway¶

Are TableGateways Worth it in Zend Framework 2?

Az üzleti logika helye: The TableGateway class contains table-aware logic, such as queries to fetch all and fetch by specific criteria. The model class is table agnostic. It only knows about the properties that it needs data for.

Then, we have the module configuration, which binds the two together. Firstly, we have a TableGateway configuration, so we know which table we’re binding to the TableGateway. Then we have the table configuration. I’ve taken this configuration further by using a HydratingResultset object. What this does, is to also implement the RowGateway pattern.

Zend Framework2: Building a CRUD app by using Table Gateway1



that's me in the middle there with them.

Nick Cave - 20,000th day on the planet Earth

Zend Framework 2 – routing & problem

Routing : http://framework.zend.com/manual/2.0/en/modules/zend.mvc.routing.html

http://zf-tutorial/album/add – 200 – works fine
http://zf-tutorial/album/add/ – 404 – The requested URL could not be matched by routing.

To handle that, just add the empty “/” in the end of route segment :

‘route’ => ‘/[:controller[/[:action[/]]]]’,

Or for “:slug” segment :

‘route’ => ‘/[:controller[/[:action[/[:slug[/]]]]]]’,

http://samsonasik.wordpress.com/2012/07/24/zend-framework-2-trailing-slash/



There you have Mick still playing away there.

Nick Cave - 20,000th day on the planet Earth