You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-10Lines changed: 73 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,95 @@
1
1
# ScaleUpStack/EasyObject
2
2
3
-
This library provides easy object handling, like
3
+
This library provides convenient object handling for a modern, defensive and strict style of programming in PHP.
4
4
5
-
* read-only properties
6
-
* typed properties
7
-
* default constructor
5
+
This library reduces boilerplate code dramatically, and offers features that PHP does not support (yet), e.g.:
8
6
9
-
No boilerplate code.
7
+
* structs,
10
8
11
-
It is a good base for Domain-Driven Design (DDD), Event Sourcing, CQRS, and an ORM that integrates in legacy applications.
9
+
* immutable objects,
10
+
11
+
* typed properties, including union types,
12
+
13
+
* default getters,
14
+
15
+
* simplified setup of test fixtures,
16
+
17
+
* no dynamic/un-defined properties in objects
18
+
19
+
20
+
This library is based on [scaleupstack/metadata] and [scaleupstack/reflection].
12
21
13
22
14
23
## Installation
15
24
16
25
Use [Composer] to install this library:
17
26
18
27
```
19
-
$ composer require scaleupventures/easy-object
28
+
$ composer require scaleupstack/easy-object
20
29
```
21
30
22
31
23
32
## Introduction
24
33
25
-
...
34
+
The main motivation while developing this library, is to simplify modelling of your business domain in the sense of Domain-Driven Design (DDD), Event-Sourcing (ES) and Command Query Responsibility Segregation (CQRS). But of course, you are not limited to that.
35
+
36
+
37
+
Currently, you can enhance your objects with default features like:
38
+
39
+
* standard getters,
40
+
41
+
* standard constructors and named constructors (a.k.a. factory methods),
42
+
43
+
* typed properties, including union types, and
44
+
45
+
* a simplified and maintainable set-up of fixtures in your tests.
46
+
47
+
And it's very easy to implement additional features.
48
+
49
+
To understand the usage of the library, there are three things:
50
+
51
+
* The library offers magic behaviour, e.g. check-out [src/Magic/VirtualGetter.php](https://github.com/scaleupstack/easy-object/tree/master/src/Magic/VirtualGetter.php) or [src/Magic/NamedConstructor.php](https://github.com/scaleupstack/easy-object/tree/master/src/Magic/NamedConstructor.php).
52
+
53
+
* Next you need some trait where you include the relevant features, e.g. [src/Traits/FixtureBuilderTrait.php](https://github.com/scaleupstack/easy-object/tree/master/src/Traits/FixtureBuilderTrait.php). To get an idea, how to include static and non-static methods, checkout [tests/Resources/Magic/ClassForNamedConstructorTesting.php](https://github.com/scaleupstack/easy-object/tree/master/tests/Resources/Magic/ClassForNamedConstructorTesting.php). (Even the magic is not included as trait here, that is not a big deal.)
54
+
55
+
* Finally you need to annotate your entities and use the correct trait, e.g. as done in [tests/Resources/Traits/EntityForTesting.php](https://github.com/scaleupstack/easy-object/tree/master/tests/Resources/Traits/EntityForTesting.php), [tests/Resources/Traits/FixtureBuilderForTesting.php](https://github.com/scaleupstack/easy-object/tree/master/tests/Resources/Traits/FixtureBuilderForTesting.php), or [tests/Resources/Magic/ClassForDispatcherTesting.php](https://github.com/scaleupstack/easy-object/tree/master/tests/Resources/Magic/ClassForDispatcherTesting.php).
56
+
57
+
Features, considered for the future, include:
58
+
59
+
* preventing dynamic/undefined properties,
60
+
61
+
* serialization,
62
+
63
+
* working on evolving data structures without updating all clients (e.g. for new versions of domain events),
64
+
65
+
* validation?
66
+
67
+
* virtual setters? (Easy; but don't you want to write intention-revealing methods to transform the state of your objects?)
68
+
69
+
* read-only properties? (I'm comfortable with default getters.)
70
+
71
+
72
+
Checkout [src/Traits/] to find out, how it works. (I'm not sure if I want to deliver these traits in the future. It might be better to provide them as examples. So it might be a good idea to copy these traits in your project; or at least create your project-specific traits that include these traits.)
73
+
74
+
75
+
This library is based on [scaleupstack/metadata] (including [scaleupstack/annotations]), and [scaleupstack/reflection]. Via extension points in this library, and in [scaleupstack/metadata] you can add additional meta-programming for your use-cases.
76
+
77
+
TODO: TBD
78
+
79
+
80
+
## Current State
81
+
82
+
This library will be developed further in the context of an internal project. I do not expect big refactorings or BC breaks. (One minor BC issue might be the removal of `src/Traits/` as mentioned above.)
83
+
84
+
If you are missing anything, feel free to contact me, or create a pull request.
85
+
86
+
Please, feel free to contact me, when you evaluate this library. I'd be happy to discuss ideas, or will be more sensible when breaking things.
87
+
26
88
27
89
28
90
## Contribute
29
91
30
-
Thanks that you want to contribute to ScaleUpVentures/EasyObject.
92
+
Thanks that you want to contribute to ScaleUpStack/EasyObject.
31
93
32
94
* Report any bugs or issues on the [issue tracker].
33
95
@@ -46,7 +108,8 @@ Thomas Nunninger <thomas.nunninger@scaleupventures.com><br>
Copy file name to clipboardExpand all lines: composer.json
+8-13Lines changed: 8 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,16 @@
1
1
{
2
2
"name": "scaleupstack/easy-object",
3
-
"description": "Easy object handling, e.g. read-only properties, typed properties, or default constructor. No boilerplate code.",
3
+
"description": "Convenient object handling for a modern, defensive and strict style of programming in PHP without boilerplate code. E.g. default getters, typed properties, named/default constructors.",
0 commit comments