Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Uid] Add Generate and Inspect commands#39883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
stof commentedJan 18, 2021
See#36405 for previous discussion about that topic. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedJan 19, 2021
Still 👎 for me. |
nicolas-grekas commentedJan 19, 2021
The commands could be provided as a third party bundle. Alternatively, we could provide them in the source, but not register them as commands, so that ppl could enable them by adding a line in their services:Symfony\Component\Uid\Command\GenerateUlidCommand:~ This approach could enable us to provide commands without cluttering the WDYT@fabpot? |
fabpot commentedJan 19, 2021
Sure, if they are hidden by default, no problems for me. |
7d4b5db tobedc3f5Comparefancyweb commentedJan 19, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Unfortunately I did not know there was already another PR for that feature in the past. I still think it's an useful feature to offer. I have removed the commands registration in the FWB and fixed the other comments. I also changed the timestamp display to be in milliseconds. I still need to fix the tests. |
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
some thougths
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Uid/Tests/Command/InspectUuidCommandTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
maxhelias commentedJan 22, 2021
Is it possible to have a format option (rfc, binary..) ? |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
836350b to325d898Comparefancyweb commentedFeb 17, 2021
I pushed a new implementation that leverages the new factories. @maxhelias I added a --format option to the generate commands. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
b9b5b7b to1eff44fCompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
ro0NL commentedFeb 23, 2021
arent we registering them as hidden? being able to default advertise |
| publicconstNORMALIZATION_FORMAT_RFC_4122 ='rfc_4122'; | ||
| publicconstNORMALIZATION_FORMAT_BASE58 ='base58'; | ||
| publicconstNORMALIZATION_FORMAT_BASE32 ='base32'; | ||
| publicconstNORMALIZATION_FORMAT_RFC4122 ='rfc4122'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
i feel like we should move the consts toAbstractUid
nicolas-grekasFeb 23, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why?AbstractUid nor theUid component wouldn't use them anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
because the formats are leaking now:The ULID output format: base32, base58 or rfc4122
nicolas-grekasFeb 23, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think these consts in Serializer are legit.
Then, the duplication in Uid is legit also - these are from different domains.
Also, the commands (on the cli), use inline values.
In the end, these consts in Uid won't serve any purpose for the devs.
They would actually make the public API of the component more complex to me.
I'd prefer not to add them as you might have understood :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
i think both serializer+console are duplicating what could beAbstractUid::toFormat($format)
nicolas-grekasFeb 23, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Oh, then I'd recommend splitting this discussion into a separate PR or issue.
nicolas-grekas commentedFeb 23, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Nope: we'renot registering them by default, so that we'll ask ppl to opt-in to list them. |
ba8a28b toaf59bfdCompare
nicolas-grekas left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Don't miss updating the description of the PR :)
Uh oh!
There was an error while loading.Please reload this page.
002f62b to8036d86CompareCo-authored-by: Nicolas Grekas <nicolas.grekas@gmail.com>
nicolas-grekas commentedFeb 25, 2021
Thank you@fancyweb. |
Uh oh!
There was an error while loading.Please reload this page.
After some time using the component, I realized I often needed to quickly generate new ulids or to convert them from one format to another so I thought having those commands would be useful.
Usage
Generate a ULID - outputs N ULID(s) separated by new lines in base 32, base 58 or RFC 4122 format
Generate 1 ULID now
php bin/console ulid:generateGenerate 1 ULID with a specific timestamp
php bin/console ulid:generate --time="2021-02-02 14:00:00"Generate 2 ULIDs and ouput the RFC4122 format
php bin/console ulid:generate --count=2 --format=rfc4122Generate a UUID - outputs N UUID(s) separated by new lines in RFC 4122, base 58 or base 32 format
Generate 1 UUID (defaults from the underlying factory)
php bin/console uuid:generateGenerate 1 time-based UUID now
php bin/console uuid:generate --time-based=nowGenerate 1 time-based UUID with a specific timestamp
php bin/console uuid:generate --time-based="2021-02-02 14:00:00"Generate 1 time-based UUID with a specific node
php bin/console uuid:generate --time-based=now --node=fb3502dc-137e-4849-8886-ac90d07f64a7Generate 1 name-based UUID (there must be a default namespace in the underlying factory)
php bin/console uuid:generate --name-based=fooGenerate 1 name-based UUID with a specific namespace (overrides the default namespace from the underlying factory)
php bin/console uuid:generate --name-based=foo --namespace=fb3502dc-137e-4849-8886-ac90d07f64a7Generate 1 random-based UUID
php bin/console uuid:generate --random-basedGenerate 2 UUIDs and output their base 58 format
php bin/console uuid:generate --count=2 --format=base58Inspect a ULID - outputs base32, base58 and RFC 4122 formats of a ULID and its humand readable timestamp if it is time-based
php bin/console ulid:inspect 01EWAKBCMWQ2C94EXNN60ZBS0Qphp bin/console ulid:inspect 1BVdfLn3ERmbjYBLCdaaLWphp bin/console ulid:inspect 01771535-b29c-b898-923b-b5a981f5e417Inspect a UUID - outputs RFC 4122, base 58 and base 32 formats of a UUID and its human readable timestamp
php bin/console uuid:inspect a7613e0a-5986-11eb-a861-2bf05af69e52php bin/console uuid:inspect MfnmaUvvQ1h8B14vTwt6dXphp bin/console uuid:inspect 57C4Z0MPC627NTGR9BY1DFD7JJRegister the commands
YAML
PHP