Symfony\Component\Console\Output\OutputInterface; class SomeCommand extends Command { protected static $defaultName = 'app:some-command'; protected function execute(InputInterface $input, OutputInterface $output) { // ... $cursor = new Cursor($output); // argument for left/right is "number of columns" (1 by default) // argument for top/bottom is "number of rows" (1 by default) $cursor->moveUp(2)->moveRight(); $cursor->moveDown(); // move to an arbitrary (column, row) position $cursor->moveToPosition(7, 15); // you can show/hide the cursor, save/restore its position, etc. $cursor->savePosition()->hide(); } }
Symfony\Component\Console\SingleCommandApplication; require __DIR__.'/vendor/autoload.php'; (new SingleCommandApplication()) ->setCode( function (InputInterface $input, OutputInterface $output) { // add here the code of your console command... } ) ->run(); #!/usr/bin/env php <?php use Dbu\SnakeBundle\Command\SnakeCommand; use Symfony\Component\Console\Application; require __DIR__.'/vendor/autoload.php'; $app = new Application(); $app->add(new SnakeCommand()); $app->setDefaultCommand('game:snake'); $app->run(); 5.1
her party!} male {{organizer_name} has invited you for his party!} other {{organizer_name} have invited you for their party!} }'; // prints "Ryan has invited you for his party!" echo $translator->trans($invitation, [ 'organizer_name' => 'Ryan', 'organizer_gender' => 'male', ]); Translation: Standard ICU message format https://github.com/symfony/symfony/pull/37371
dedicated Normalizer) - Just works Uid Doctrine types and generators Help needed - https://github.com/symfony/symfony/issues/36102 Uid constraint and more 5.1
'id' => 'login', 'strategy' => 'token_bucket', // or 'fixed_window' 'limit' => 10, 'rate' => ['interval' => '15 minutes'], ], new InMemoryStorage()); // blocks until 1 token is free to use for this process $limiter->reserve(1)->wait(); // ... execute the code // only claims 1 token if it's free at this moment if ($limiter->consume(1)) { // ... execute the code } RateLimiter Lock ??? Cache https://github.com/symfony/symfony/pull/37546
5.1 3.3 3.1 5.2 5.2 security: firewalls: default: # default limits to 5 login attempts per minute, # the number can be configured via "max_attempts" login_throttling: ~ # define your own RateLimiter login_throttling: limiter: login https://github.com/symfony/symfony/pull/38204
authentication https://github.com/symfony/symfony/pull/38177 2fa authentication https://github.com/scheb/2fa Help needed - https://github.com/symfony/symfony/issues/30914 Sudo mode and more
> Do you want to store user data in the database (via Doctrine)? (yes/no) [yes]: > Enter a property name that will be the unique "display" name for the user (e.g. email, username, uuid) [email]: > Will this app need to hash/check user passwords? Choose No if passwords are not needed or will be checked/hashed by some other system (e.g. a single sign-on server). Does this app need to hash/check user passwords? (yes/no) [yes]: > $ symfony console make:user
Empty authenticator [1] Login form authenticator > 1 The class name of the authenticator to create (e.g. AppCustomAuthenticator): > AppAuthenticator Choose a name for the controller class (e.g. SecurityController) [SecurityController]: > Do you want to generate a '/logout' URL? (yes/no) [yes]: > $ symfony console make:auth
add a @UniqueEntity validation annotation on your User class to make sure duplicate accounts aren't created? (yes/no) [yes]: > Do you want to send an email to verify the user's email address after registration? (yes/no) [yes]: > [WARNING] We're missing some important components. Don't forget to install these after you're finished. composer require symfonycasts/verify-email-bundle symfony/mailer What email address will be used to send registration confirmations? e.g. [email protected]: > [email protected] What "name" should be associated with that email address? e.g. "Acme Mail Bot": > Demo Bot Do you want to automatically authenticate the user after registration? (yes/no) [yes]: > $ symfony console make:registration-form
extends AbstractFormLoginAuthenticator implements Passwor return new RedirectResponse($targetPath); } - // For example : return new RedirectResponse($this->urlGenerator->generate('some_route')); - throw new \Exception('TODO: provide a valid redirect inside '.__FILE__); + return new RedirectResponse($this->urlGenerator->generate('app_login')); } protected function getLoginUrl() $ symfony console make:registration-form
'hello')] public function action() { } } class AutowireSetter { #[Required] public function setFoo(Foo $foo): void { } } https://github.com/symfony/symfony/pull/37545 https://github.com/symfony/symfony/pull/37474
support for Constraints Think of new possibilities Replace SensioFrameworkExtraBundle public function searchAction( #[RequestQuery] string $q, #[RequestQuery] int $page = 1 ) {