cycle / docs Goto Github PK
View Code? Open in Web Editor NEWCycle ORM Documentation
Home Page: https://cycle-orm.dev/docs
Cycle ORM Documentation
Home Page: https://cycle-orm.dev/docs
Add article to the docs that explains difference between this ORM and other popular solutions such as Doctrine and Eloquent.
There is the new generator in the schema-builder package. Need to add it into generator lists in documentation.
Add info about the ForeignKey attribute
An example is there: https://github.com/cycle/annotated/releases/tag/v3.4.0
Hi. All things said in docs about Cycle\Relation\Inverse
is "Most belongsTo relations can be created using the inverse option of the declared hasOne or hasMany relation".
Please add code example with inverse: ...
annotation.
It is necessary to supplement the documentation with information about the attributes.
Related gist:
https://gist.github.com/roxblnfk/15a16ebf2fcee9d23bedd99b1252121c
Suggests:
@Entity
instead of @entity
@Column
instead of @column
@Embeddable
instead of @embeddable
@HasOne
instead of @hasOne
@HasMany
instead of @hasMany
@BelongsTo
instead of @belongsTo
@RefersTo
instead of @refersTo
@ManyToMany
instead of @manyToMany
@BelongsToMorphed
instead of @belongsToMorphed
@MorphedHasMany
instead of @morphedHasMany
@Inverse
instead of @inverse
Reason:
Existing popular solutions codestyle.
The Cycle ORM documentation currently provides a few examples of using with
and load
for loading relationships, but these examples are limited and do not always cover all the possibilities of working with these methods. This can make it challenging for developers to understand and utilize Cycle ORM's functionality for data and relationship handling. Therefore, it is proposed to expand the documentation and add more diverse and realistic examples of using with and load.
Why array so unique as we must manually wrap it to Parameter object and ORM can't do it automatically ?
As docs says:
"Using Parameters
By default, any passed value will be converted into Parameter objects internally. However, you must explicitly use Parameter while specifying array values:
$select->where('id', 'in', new \Spiral\Database\Injection\Parameter([1,2,3]));
"
https://cycle-orm.dev/docs/advanced-daemonizing/2.x/en
Cycle ORM attempts to simplify the usage of the library in daemonized applications such as PHP workers running under RoadRunner, Swoole and etc.
"etc" (et cetera) literally means "and so on" or "and other". Thus, "and and other" is logically silly. Please drop unnecessary conjunction.
https://cycle-orm.dev/docs/database-configuration/2.x/en
To create new database connection add a new section or alter existed options of
drivers
section of your configuration, you can useenv
function to keep your passwords and usernames separately.
Existing options. "Existed" means they were there, but no longer are. You can not alter what is absent.
Hey,
In the Annotated Entities section (https://github.com/cycle/docs/blob/master/annotated/entity.md) you have the following statement about primary keys.
" (you still can create a compound primary key, see below)."
but their is no further mention of how to create compound primary keys.
Can you please add this documentation or link to the page that has this information?
In the Contributing section invite to discord "https://discord.gg/FZ9BCWg" is invalid or expired : (
relation/embedded.md
page starts by using user credentials as an example of embedded entity and then midway from the Querying
section switches to addresses. It be better if it continued using the user credentials example.
When working with ORM, users often encounter the error
Cycle\ORM\Exception\TransactionException: Transaction can't be finished. Some relations can't be resolved:
Create new `asset`
- asset.services:asset (Cycle\ORM\Relation\ShadowBelongsTo)
This is related to the fact that the nullable: true option is not set in HasMany, HasOne, and other relations.
This needs to be better highlighted in the documentation.
I tried to get Cycle ORM 2 running, but it seems like there are some things missing in the documentation. I've started here:
https://cycle-orm.dev/docs/intro-install/2.x/en
I then read this part: https://cycle-orm.dev/docs/intro-install/2.x/en#configuration-manually-configure-mapping (direct links to anchor don't seem to work, but there's an ID in the code). However, I don't want to skip the annotation part as I don't want to manually define my schema so I skip this part.
Next I therefore try to define my entity: https://cycle-orm.dev/docs/intro-install/2.x/en#define-entity. This works fine, the class loader also manages to find my class, however, in "Define Entity" we are creating the entity in the src
folder and then scan __DIR__
. If I try that, it will fail because that will try to load some classes in the vendor
directory which can't be loaded because I don't have Illuminate/Collection installed. I replaced that with the src
folder and managed to get it working.
I then tried to register my orm schema with this $orm = $orm->with(schema: new \Cycle\ORM\Schema($schema));
, but here $orm
isn't defined because I skipped the part where we manually register the schema. I also tried to keep it, but then I have a bunch of collisions with Schema
..
I read the whole thing twice, but I don't see how the documentation here should work.
We need to add more visual disclosure that user should NOT modify $select
property of repository (or make it private) to build local queries.
Хотелось бы видеть больше такой информации, как Best/Bad Practices, разборы полётов и тонких моментов.
Вот некоторые вопросы:
Entities:
post_id
, user_id
getUser()
, setUser()
camelCase
, то Cycle создаёт двойника в under_scope
и иногда с этим бывают проблемы. Хорошо бы осветить Best/Bad Practices на эту тему.string
. Json во что-то кастуется?@return ArrayCollection|Entity[]
.getUser()
вероятен Fatal Erorr, т.к.поле не инициализировано. Может лучше вернуть null из геттара, а в случае записи в БД ждать ошибки из DBAL?Repository:
final class ArchiveRepository
{
private PostRepository $postRepo;
public function __construct(ORMInterface $orm)
{
/** @var PostRepository $postRepo */
$postRepo = $orm->getRepository(Post::class);
$this->postRepo = $postRepo;
}
//...
}
Возможно то, что я написал, в доке уже есть.. но как-то это сложно всё бывает найти.
Со временем могу пополнять список вопросов
https://cycle-orm.dev/docs/query-builder-extended
Complex/Group Where Conditions
Here we can see 2 blocks like:
$select->where('id', 1)->where(function (SelectQuery $select) {
$select->where('status', 'active')->orWhere('id', 10);
});
and
$select->where('id', 1)->orWhere(function (QueryBuilder $select) {
$select->where('status', 'active')->andWhere('id', 10);
});
It is not clear why in similar situations it can be used QueryBuilder or SelectQuery
I have some questions:
where
and orWhere
? Should it be unificated?Argument 1 passed to ...Repository::...Dictionary\{closure}() must be an instance of Spiral\Database\Query\SelectQuery, instance of Cycle\ORM\Select\QueryBuilder given, called in /var/www/vendor/cycle/orm/src/Select/QueryBuilder.php on line 248
Could you clarify in doc the reason when I should use SelectQuery as arg and where I should use QueryBuilder?
Cycle\ORM\Entity\Behavior
does not exists anymore
Need to add more examples about migrations
Could you provide some information on how to run the test suite? I can't seem to get the tests that use a database connection to work (I'm probably doing something wrong with Docker). It can be a useful addition to the docs as well!
When I'm trying to start using example in "Very quick start section":
PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Cycle\ORM\Promise\ProxyFactory::__construct(), 0 passed in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/bootstrap/src/Bootstrap.php on line 90 and at least 2 expected in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/proxy-factory/src/Promise/ProxyFactory.php:55
Stack trace:
#0 /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/bootstrap/src/Bootstrap.php(90): Cycle\ORM\Promise\ProxyFactory->__construct()
#1 /Users/siarhei/Code/experiments/try-cycle-orm/bootstrap.php(33): Cycle\Bootstrap\Bootstrap::fromConfig(Object(Cycle\Bootstrap\Config))
#2 /Users/siarhei/Code/experiments/try-cycle-orm/config/cycle-cli.php(3): require_once('/Users/siarhei/...')
#3 /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/bootstrap/bin/cycle(26): require_once('/Users/siarhei/...')
#4 {main}
thrown in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/proxy-factory/src/Promise/ProxyFactory.php on line 55
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Cycle\ORM\Promise\ProxyFactory::__construct(), 0 passed in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/bootstrap/src/Bootstrap.php on line 90 and at least 2 expected in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/proxy-factory/src/Promise/ProxyFactory.php on line 55
ArgumentCountError: Too few arguments to function Cycle\ORM\Promise\ProxyFactory::__construct(), 0 passed in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/bootstrap/src/Bootstrap.php on line 90 and at least 2 expected in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/proxy-factory/src/Promise/ProxyFactory.php on line 55
Call Stack:
0.0006 398584 1. {main}() /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/bootstrap/bin/cycle:0
0.0011 400008 2. require_once('/Users/siarhei/Code/experiments/try-cycle-orm/config/cycle-cli.php') /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/bootstrap/bin/cycle:26
0.0012 403016 3. require_once('/Users/siarhei/Code/experiments/try-cycle-orm/bootstrap.php') /Users/siarhei/Code/experiments/try-cycle-orm/config/cycle-cli.php:3
0.0050 677104 4. Cycle\Bootstrap\Bootstrap::fromConfig() /Users/siarhei/Code/experiments/try-cycle-orm/bootstrap.php:33
0.0227 2199136 5. Cycle\ORM\Promise\ProxyFactory->__construct() /Users/siarhei/Code/experiments/try-cycle-orm/vendor/cycle/bootstrap/src/Bootstrap.php:90
I don't know yet, is its documentation or cycle/bootsrap
issue?
Thank you.
docs/docs/en/relation/refers-to.md
Lines 59 to 60 in 3e97d5c
I really need a page with a description of the load
method options
$countryList = $select
->load('cities', [
'orderBy' => ['name' => 'ASC'],
'where' => [
'deleted_at' => null,
],
// etc
])
->orderBy('name')
->fetchData();
Also we need more examples for with
method.
auto-generated keys can lead to unexpected behavior.
It should be emphasized that in all relations it is better to specify the inner/outer keys manually
documentation still says to use
AnnotationRegistry::registerLoader
Originally posted by @tenmajkl in cycle/annotated#76 (comment)
https://cycle-orm.dev/docs/advanced-typecasting/2.x/en
As I understand the bottom example should be UUID instead string, as is the main objective of typecasting, isn't it?
use Cycle\Annotated\Annotation\Entity;
+ use Whatever\Uuid;
#[Entity(
typecast: [
\Cycle\ORM\Parser\Typecast::class,
App\UuidTypecast::class,
'carbon_typecast'
]
)]
class User
{
#[Cycle\Column(type: 'string', typecast: 'uuid')]
+ public Uuid $uuid;
- public string $uuid;
}
In some cases, you need tables in the database that are not linked to entities. For such cases you need to write manually migration file. The documentation lacks a description of all the possibilities for adding columns, indexes, etc.
Example of ORM configuration to use ProxyFactory from here
https://github.com/cycle/docs/blob/2f15cdb4bba7f8c45c5c807bc461420a3f890828/advanced/promise.md#proxies-and-promises
actually looks like this for me:
use Cycle\ORM\Promise\ConflictResolver;
use Cycle\ORM\Promise\Declaration\Extractor;
use Cycle\ORM\Promise\Printer;
use Cycle\ORM\Promise\Traverser;
use Doctrine\Instantiator\Instantiator;
// ....
$traverser = new Traverser();
$extractor = new Extractor(
new Extractor\Constants(),
new Extractor\Properties(),
new Extractor\Methods($traverser)
);
$orm = $orm->withPromiseFactory(new \Cycle\ORM\Promise\ProxyFactory(
$extractor,
new Printer($extractor, $traverser, new ConflictResolver()),
new Instantiator()
));
Add link about that into Issue template
Describe how does where
condition works in a hierarchy.
Note:
Field that not found in all hierarchy will be prefixed with the most parent table.
Related PR: cycle/orm#405
This method is deprecated
Type: Cycle\Annotated\Exception\AnnotationException
Code: 0
Message: [Semantical Error] The annotation "@manytomany" in property App\Entity\Post::$tags was never imported. Did you maybe forget to add a "use" statement for this annotation?
File: /var/www/api/vendor/cycle/annotated/src/Configurator.php
Line: 96
I did not give the code because it is incorrectly formatted here. In any case, this is a fragment from the documentation
This is not a documentation issue, I think, but I don't know where to post it.
First of all, in this topic https://cycle-orm.dev/docs/intro-quick-start and in Schema Generation chapter when I am trying to dump
print_r($classLocator->getClasses());
I get warnings:
( ! ) Deprecated: Class Zend\Hydrator\ClassMethods is deprecated, please use Zend\Hydrator\ClassMethodsHydrator instead in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/zendframework/zend-hydrator/src/ClassMethods.php on line 21
--
1 | 0.0003 | 402736 | {main}( ) | .../index.php:0
2 | 0.0013 | 428736 | Spiral\Tokenizer\ClassLocator->getClasses( ) | .../index.php:32
3 | 0.7740 | 560928 | Spiral\Tokenizer\ClassLocator->classReflection( ) | .../ClassLocator.php:30
4 | 0.7740 | 561464 | __construct ( ) | .../AbstractLocator.php:93
5 | 0.7740 | 561520 | spl_autoload_call ( ) | .../AbstractLocator.php:93
6 | 0.7740 | 561576 | Composer\Autoload\ClassLoader->loadClass( ) | .../AbstractLocator.php:93
7 | 0.7741 | 561736 | Composer\Autoload\includeFile( ) | .../ClassLoader.php:322
8 | 0.7741 | 561976 | include( '/Users/siarhei/Code/experiments/try-cycle-orm/vendor/zendframework/zend-hydrator/src/ClassMethods.php' ) | .../ClassLoader.php:444
9 | 0.7741 | 562296 | trigger_error ( ) | .../ClassMethods.php:21
Deprecated: Class Zend\Hydrator\ArraySerializable is deprecated, please use Zend\Hydrator\ArraySerializableHydrator instead in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/zendframework/zend-hydrator/src/ArraySerializable.php on line 21
--
1 | 0.0003 | 402736 | {main}( ) | .../index.php:0
2 | 0.0013 | 428736 | Spiral\Tokenizer\ClassLocator->getClasses( ) | .../index.php:32
3 | 0.7756 | 585696 | Spiral\Tokenizer\ClassLocator->classReflection( ) | .../ClassLocator.php:30
4 | 0.7756 | 586232 | __construct ( ) | .../AbstractLocator.php:93
5 | 0.7756 | 586288 | spl_autoload_call ( ) | .../AbstractLocator.php:93
6 | 0.7756 | 586344 | Composer\Autoload\ClassLoader->loadClass( ) | .../AbstractLocator.php:93
7 | 0.7757 | 586504 | Composer\Autoload\includeFile( ) | .../ClassLoader.php:322
8 | 0.7757 | 588448 | include( '/Users/siarhei/Code/experiments/try-cycle-orm/vendor/zendframework/zend-hydrator/src/ArraySerializable.php' ) | .../ClassLoader.php:444
9 | 0.7757 | 588768 | trigger_error ( ) | .../ArraySerializable.php:21
Deprecated: Class Zend\Hydrator\Reflection is deprecated, please use Zend\Hydrator\ReflectionHydrator instead in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/zendframework/zend-hydrator/src/Reflection.php on line 21
--
1 | 0.0003 | 402736 | {main}( ) | .../index.php:0
2 | 0.0013 | 428736 | Spiral\Tokenizer\ClassLocator->getClasses( ) | .../index.php:32
3 | 0.7772 | 619952 | Spiral\Tokenizer\ClassLocator->classReflection( ) | .../ClassLocator.php:30
4 | 0.7772 | 620488 | __construct ( ) | .../AbstractLocator.php:93
5 | 0.7772 | 620544 | spl_autoload_call ( ) | .../AbstractLocator.php:93
6 | 0.7772 | 620600 | Composer\Autoload\ClassLoader->loadClass( ) | .../AbstractLocator.php:93
7 | 0.7773 | 620760 | Composer\Autoload\includeFile( ) | .../ClassLoader.php:322
8 | 0.7773 | 621000 | include( '/Users/siarhei/Code/experiments/try-cycle-orm/vendor/zendframework/zend-hydrator/src/Reflection.php' ) | .../ClassLoader.php:444
9 | 0.7773 | 621320 | trigger_error ( ) | .../Reflection.php:21
Deprecated: Class Zend\Hydrator\ObjectProperty is deprecated, please use Zend\Hydrator\ObjectPropertyHydrator instead in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/zendframework/zend-hydrator/src/ObjectProperty.php on line 21
--
1 | 0.0003 | 402736 | {main}( ) | .../index.php:0
2 | 0.0013 | 428736 | Spiral\Tokenizer\ClassLocator->getClasses( ) | .../index.php:32
3 | 0.7777 | 624368 | Spiral\Tokenizer\ClassLocator->classReflection( ) | .../ClassLocator.php:30
4 | 0.7777 | 624904 | __construct ( ) | .../AbstractLocator.php:93
5 | 0.7777 | 624960 | spl_autoload_call ( ) | .../AbstractLocator.php:93
6 | 0.7777 | 625016 | Composer\Autoload\ClassLoader->loadClass( ) | .../AbstractLocator.php:93
7 | 0.7777 | 625176 | Composer\Autoload\includeFile( ) | .../ClassLoader.php:322
8 | 0.7777 | 690952 | include( '/Users/siarhei/Code/experiments/try-cycle-orm/vendor/zendframework/zend-hydrator/src/ObjectProperty.php' ) | .../ClassLoader.php:444
9 | 0.7777 | 691272 | trigger_error ( ) | .../ObjectProperty.php:21
and I get printed classes.
But, after that when I am trying to create a schema receive fatal error:
Fatal error: Cannot declare class Psr\Log\Test\DummyTest, because the name is already in use in /Users/siarhei/Code/experiments/try-cycle-orm/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php on line 140
--
1 | 0.0003 | 414288 | {main}( ) | .../index.php:0
2 | 0.8121 | 2184360 | Cycle\Schema\Compiler->compile( ) | .../index.php:50
3 | 0.8121 | 2184360 | Cycle\Annotated\Embeddings->run( ) | .../Compiler.php:43
4 | 0.8121 | 2184360 | Spiral\Tokenizer\ClassLocator->getClasses( ) | .../Embeddings.php:55
5 | 1.7872 | 2445008 | Spiral\Tokenizer\ClassLocator->classReflection( ) | .../ClassLocator.php:30
6 | 1.7872 | 2445544 | __construct ( ) | .../AbstractLocator.php:93
7 | 1.7872 | 2445608 | spl_autoload_call ( ) | .../AbstractLocator.php:93
8 | 1.7872 | 2445672 | Composer\Autoload\ClassLoader->loadClass( ) | .../AbstractLocator.php:93
9 | 1.7873 | 2445832 | Composer\Autoload\includeFile( ) | .../ClassLoader.php:322
What I am doing wrong? Help me, please
Thank you.
// del
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.