cakephp-dto

CakePHP DTO plugin - quickly generate useful data transfer objects for your app (mutable/immutable)

MIT License

Downloads
61.6K
Stars
24
Committers
6
cakephp-dto - 2.2.1 Latest Release

Published by dereuromark 7 months ago

Fixes

  • Only show changed exit code for verbose or dry-run.
cakephp-dto - 2.2.0

Published by dereuromark 8 months ago

Improvements

Added Enum support, mainly int/string backed enums are now handled gracefully.

Example:

<dto name="FooBar" immutable="true">
	...
	<field name="someUnit" type="\App\Model\Enum\MyUnit"/>
	<field name="someStringBacked" type="\App\Model\Enum\MyStringBacked"/>
	<field name="someIntBacked" type="\App\Model\Enum\MyIntBacked"/>
</dto>

Fixes

Fixed up immutable DTOs for setter (withOrFail instead of setOrFail). Please make sure you are not using the former one.

Full Changelog: https://github.com/dereuromark/cakephp-dto/compare/2.1.0...2.2.0

cakephp-dto - 2.1.0

Published by dereuromark 8 months ago

Improvements

Added DTO schema generator from JSON schema or JSON example data
Navigate to

/admin/cake-dto/generate

locally in order to leverage it.

Also:

  • Collision avoidance for singular of collections when that field is already present in the DTO. One must set a different one then to be able to use the collection item methods.
  • Multiple depths of namespace is now supported.
cakephp-dto - 2.0.0

Published by dereuromark about 1 year ago

CakePHP 5 compatible release

Enjoy DTOs in CakePHP apps the easy way: Minimal configuration, no manual coding needed.

cakephp-dto - 2.0.0-RC

Published by dereuromark about 1 year ago

CakePHP 5 compatible pre-release

Please test. Once this has been tested and approved, the stable release can be tagged.

cakephp-dto - 1.8.0

Published by dereuromark about 1 year ago

Improvements

  • Allow global key type config (Dto::TYPE_DEFAULT by default which uses Dto::TYPE_CAMEL)
cakephp-dto - 1.7.0

Published by dereuromark about 1 year ago

Fixes

  • Fixed generation for namespaced plugin names, e.g. Foo/Bar plugin.

Improvements

  • Extending from any DTO compatible class is now possible.
cakephp-dto - 1.6.0

Published by dereuromark over 1 year ago

Improvements

  • Allow Dto suffix to be configurable, or removed using empty string.
  • PHP 7.4+ now.
cakephp-dto - 1.5.2

Published by dereuromark almost 2 years ago

Fixes

Full Changelog: https://github.com/dereuromark/cakephp-dto/compare/1.5.1...1.5.2

cakephp-dto - 1.5.1

Published by dereuromark almost 2 years ago

Improvements

  • Allow digits in DTO names
  • Relax file names for DTO configs
cakephp-dto - 1.5.0

Published by dereuromark almost 3 years ago

Fixes

Serializable

Implementing Serializable interface is deprecated in PHP 8.1 without having the magic methods in place.
Those have now been added. They return associative arrays however and work differently than the explicit serialize() call which returns a string.

Collections

Fixed duplication issue with using collections and name collisions in certain aliasing cases.

Note: This can be BC impacting if you use aliasing here, double-check this before upgrading

Example

<field name="labels" type="FilterElement[]"/>
<field name="brands" type="FilterElement[]"/>

Before, this was creating methods using the singular "FilterElement" instead of "Label" or "Brand".
This is now fixed.

cakephp-dto - 1.4.0

Published by dereuromark almost 3 years ago

Improvements

Allow custom DTO specification file finder class to be configured - using Configure key 'CakeDto.finder'. Thx to @jorisvaesen for this contribution.

cakephp-dto - 1.3.0

Published by dereuromark almost 3 years ago

Improvements

  • Added set*OrFail() wrapper to make it easier to have an early error system for invalid null setting.

CakePHP 4.3 checked/approved and CakePHP 4.2+ / PHP 7.3+ now.

cakephp-dto - 1.2.4

Published by dereuromark about 3 years ago

Fixes

  • Uses configured App namespace by default
cakephp-dto - 1.2.3

Published by dereuromark about 3 years ago

Improvements

Stricter validation for collection type: type[] instead of type required

cakephp-dto - 1.2.2

Published by dereuromark about 3 years ago

Fixes

Adjusted to allow for latest PHPStan strict rules.

cakephp-dto - 1.2.1

Published by dereuromark about 3 years ago

Fixes

Small fix in builder.

cakephp-dto - 1.2.0

Published by dereuromark almost 4 years ago

Improvements

Stricter validation for field names and types.

  • If a field name is not camelBacked
  • If setting through fromArray() contains not matching scalar types for immutable or any type for mutable objects

Default value object instantiation has been improved.
factory XML attribute added in case the default constructor option is not sufficient for some edge cases.
The following should work out of the box for also string input (e.g. from API data):

<field name="created" type="\Cake\I18n\FrozenTime"/>

BC breaking impact

The config scalarTypeHints has been renamed to scalarAndReturnTypes since this is closer to what it stands for.
Since it defaults to true either way, this is a small BC break early in the 1.x release.

Please make sure you regenerate all DTOs after this upgrade!

cakephp-dto - 1.1.0

Published by dereuromark about 4 years ago

Fixes

  • Fixed scalarTypeHints defaulting to true now with PHP 7.2+
  • Fixed immutable generation for the case of collections

Improvements

  • Allow nullable element for collections, e.g. ?int[] as (int|null)[]
  • Allow new major of sebastian/diff
cakephp-dto - 1.0.0

Published by dereuromark over 4 years ago

CakePHP 4 stable release

This plugin will provide you with a tool to quickly generate custom and optimized DTOs for your special use cases.
They are close to Entity classes, but are not bound to the ORM and DB layer.

  • We can have full IDE autocomplete and typehinting.
  • Typehinted
  • Mutable or Immutable
  • PHPStan/Psalm ready for strict analyzing
Package Rankings
Top 7.08% on Packagist.org
Badges
Extracted from project README
CI codecov Minimum PHP Version Coding Standards