Giter VIP home page Giter VIP logo

docs's People

Contributors

admad avatar alexndr-novikov avatar bautrukevich avatar butschster avatar d3ah avatar daniellienert avatar gam6itko avatar lotyp avatar machour avatar mark-gerarts avatar mrakolice avatar msmakouz avatar patoui avatar roquie avatar roxblnfk avatar rundfunk avatar rustamwin avatar serafimarts avatar sergey-telpuk avatar someson avatar stapik avatar sylbru avatar thenotsoft avatar u-mulder avatar vitalylitvinov74 avatar vizh avatar vjik avatar vvval avatar wolfy-j avatar zhukovra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docs's Issues

Parametes conversion

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]));"

Using where condition as closure

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:

  1. Is it difference between where and orWhere? Should it be unificated?
  2. When we tried to use SelectQuery we've caught exception like 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?

Enhance documentation with more examples of `with` and `load` usage for efficient relationship handling

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.

Continue with the same example for embedded entities

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.

Customization typecasting example code typo

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;
}

User should specify inner/outer keys

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

Errors with examples

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.

[JTI] `where` condition

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

Развитие документации: Best/Bad Practices

Хотелось бы видеть больше такой информации, как Best/Bad Practices, разборы полётов и тонких моментов.

Вот некоторые вопросы:

  • Entities:

    • Чем полезно и стоит ли при использовании связей декларировать в сущностях автогенерируемые поля, например post_id, user_id
    • Стоит ли делать сеттеры/геттеры на эти поля? Делать публичными или лучше совместить с сеттерами/геттерами полей getUser(), setUser()
    • Если я описываю поле в camelCase, то Cycle создаёт двойника в under_scope и иногда с этим бывают проблемы. Хорошо бы осветить Best/Bad Practices на эту тему.
      Я пока пришёл к выводу, что лучше создавать поля в under_scope, а геттеры/сеттеры в camelCase
    • Тема типизации в сущностях
      • Есть поля с автокастом - их можно хорошо протипизировать. То, что не кастуется, походу string. Json во что-то кастуется?
      • Есть поля, задающие связи - тут всё не просто - вот тебе, читатель, ссылка на References and Proxies, в phpDoc указывать, например, @return ArrayCollection|Entity[].
      • Правильно ли поля-связи засовывать как параметры в конструктор, если эти связи обязательные (не могут быть null)? Если нет, то при вызове getUser() вероятен Fatal Erorr, т.к.поле не инициализировано. Может лучше вернуть null из геттара, а в случае записи в БД ждать ошибки из DBAL?
    • Публичные свойства вместо сеттеров/геттеров - каков опыт применения? Почему стоит или не стоит отказаться
  • Repository:

    • Раскрыть тему того, как засунуть свой Repository в свой контейнер.
      Например, можно на каждый репозиторий вручную написать фабрику. А можно реализовать такой то интерфейс и подсунуть туда то и при получении схемы Cycle сам задефайнит фабрики для репозиториев.
    • Лучшие практики на тему того, как разнести репозиторий. Например, для работы с архивными записями постов, я делал так:
      final class ArchiveRepository
      {
          private PostRepository $postRepo;
          public function __construct(ORMInterface $orm)
          {
              /** @var PostRepository $postRepo */
              $postRepo = $orm->getRepository(Post::class);
              $this->postRepo = $postRepo;
          }
          //...
      }

Возможно то, что я написал, в доке уже есть.. но как-то это сложно всё бывает найти.
Со временем могу пополнять список вопросов

Proxy configuration snippet is inaccurate

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 more info about `nullable` option in relations

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.

Example from https://cycle-orm.dev/docs/intro-cli doesn't work

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.

Repository DX issue - mutable Select

We need to add more visual disclosure that user should NOT modify $select property of repository (or make it private) to build local queries.

"and etc" and other issues.

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 use env 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.

Inverse example needed

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.

`Cycle\ORM\Select::load` options docs required

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.

Docs for migrations

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.

Running the test suite

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!

Improve annotations codestyle using UpperCamelCase instead of lowerCamelCase

Suggests:

  1. @Entity instead of @entity
  2. @Column instead of @column
  3. @Embeddable instead of @embeddable
  4. @HasOne instead of @hasOne
  5. @HasMany instead of @hasMany
  6. @BelongsTo instead of @belongsTo
  7. @RefersTo instead of @refersTo
  8. @ManyToMany instead of @manyToMany
  9. @BelongsToMorphed instead of @belongsToMorphed
  10. @MorphedHasMany instead of @morphedHasMany
  11. @Inverse instead of @inverse

Reason:

Existing popular solutions codestyle.

An example of a many-to-many relationship from the documentation gives an error

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

Mistakes in Cycle ORM installation

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.