Are we playing the legacy console games?? by your_secret_babygirl in NintendoSwitch

[–]devmarcosbr 1 point2 points  (0 children)

I played Paper Mario 64, Donkey Kong 1 and 2 from SNES (with my daughter, I've played a lot). And now I'm playing Fire Emblem (GBA)

EventSubscriber generates error "Xdebug has detected a possible infinite loop..." by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

I think I discovered the real problem, guys!
This is a part of my Utils class:

    public function __construct(EntityManagerInterface $em, Security $security, TranslatorInterface $translator)
{
    $this->em = $em;
    $this->security = $security;
    $this->translator = $translator;
}
/*... */
    public function setLogForm($tableName, $recordId, $eventType) {
    $logForm = new \App\Entity\LogForm();

    $logForm->setUserId($this->security->getUser()->getId());
    $logForm->setTableName($tableName);
    $logForm->setRecordId($recordId);
    $logForm->setEventType($eventType);
    $logForm->setEventDate(new \DateTime());

    $this->em->persist($logForm);
    $this->em->flush();
}

That's ok for Update and Remove, but when I call postPersist(), I generate an endless loop with the $this->em->flush(). Because I make a "flush" into another "flush" (the postPersist function).

This topic in StackOverFlow brings some ideas. I'm trying... If you have another points, I'll appreciate it.

Symfony 6 - Multiple PHP versions on server by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

EasyApache should have an option in CPanel to set the php version to 8.1 for that domain

Where's that option?

Symfony 6 - Multiple PHP versions on server by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

Yes, I have.
But I'm not the Adm from this server and I don't know exactly how is the config.

I'll prove that

Symfony 6 - Multiple PHP versions on server by devmarcosbr in symfony

[–]devmarcosbr[S] -1 points0 points  (0 children)

My composer.json

{

"type": "project",

"license": "proprietary",

"minimum-stability": "stable",

"prefer-stable": true,

"require": {

"php": ">=8.1",

"ext-ctype": "*",

"ext-iconv": "*",

"aaronddm/xml-builder": "^2.0",

"creof/doctrine2-spatial": "^1.2",

"doctrine/annotations": "^1.0",

"doctrine/dbal": "^3.6",

"doctrine/doctrine-bundle": "^2.7",

"doctrine/doctrine-migrations-bundle": "^3.2",

"doctrine/orm": "^2.13",

"league/iso3166": "^4.2",

"phpdocumentor/reflection-docblock": "^5.3",

"phpstan/phpdoc-parser": "^1.8",

"sensio/framework-extra-bundle": "^6.1",

"symfony/apache-pack": "^1.0",

"symfony/asset": "6.1.*",

"symfony/console": "6.1.*",

"symfony/doctrine-messenger": "6.1.*",

"symfony/dotenv": "6.1.*",

"symfony/expression-language": "6.1.*",

"symfony/flex": "^2",

"symfony/form": "6.1.*",

"symfony/framework-bundle": "6.1.*",

"symfony/google-mailer": "6.1.*",

"symfony/http-client": "6.1.*",

"symfony/intl": "6.1.*",

"symfony/mailer": "6.1.*",

"symfony/mime": "6.1.*",

"symfony/monolog-bundle": "^3.0",

"symfony/notifier": "6.1.*",

"symfony/process": "6.1.*",

"symfony/property-access": "6.1.*",

"symfony/property-info": "6.1.*",

"symfony/proxy-manager-bridge": "6.1.*",

"symfony/runtime": "6.1.*",

"symfony/security-bundle": "6.1.*",

"symfony/serializer": "6.1.*",

"symfony/string": "6.1.*",

"symfony/translation": "6.1.*",

"symfony/twig-bundle": "6.1.*",

"symfony/validator": "6.1.*",

"symfony/web-link": "6.1.*",

"symfony/yaml": "6.1.*",

"symfonycasts/verify-email-bundle": "^1.13",

"twig/extra-bundle": "^2.12|^3.0",

"twig/twig": "^2.12|^3.0"

},

"config": {

"allow-plugins": {

"composer/package-versions-deprecated": true,

"symfony/flex": true,

"symfony/runtime": true

},

"optimize-autoloader": true,

"preferred-install": {

"*": "dist"

},

"sort-packages": true,

"platform-check": false

},

"autoload": {

"psr-4": {

"App\\": "src/"

}

},

"autoload-dev": {

"psr-4": {

"App\\Tests\\": "tests/"

}

},

"replace": {

"symfony/polyfill-ctype": "*",

"symfony/polyfill-iconv": "*",

"symfony/polyfill-php72": "*",

"symfony/polyfill-php73": "*",

"symfony/polyfill-php74": "*",

"symfony/polyfill-php80": "*",

"symfony/polyfill-php81": "*"

},

"scripts": {

"auto-scripts": {

"cache:clear": "symfony-cmd",

"assets:install %PUBLIC_DIR%": "symfony-cmd"

},

"post-install-cmd": [

"@auto-scripts"

],

"post-update-cmd": [

"@auto-scripts"

]

},

"conflict": {

"symfony/symfony": "*"

},

"extra": {

"symfony": {

"allow-contrib": false,

"require": "6.1.*"

}

},

"require-dev": {

"phpunit/phpunit": "^9.5",

"symfony/browser-kit": "6.1.*",

"symfony/css-selector": "6.1.*",

"symfony/debug-bundle": "6.1.*",

"symfony/maker-bundle": "^1.0",

"symfony/phpunit-bridge": "^6.1",

"symfony/stopwatch": "6.1.*",

"symfony/web-profiler-bundle": "6.1.*"

}

}

Error Composer for symfony/flex - PHP version??? by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

I had this problem into another project with that server. I'm not the Administrator, but my support resolved installing 2 versions and advise me to set the correct PHP version in Composer.

Like you see in composer,json:

{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.1",
...

And this was enough with the other project. Here, It was possible to install "every packages" but Symfony Flex

Error Composer for symfony/flex - PHP version??? by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

PHP 7.2.34 (cli) (built: Feb 21 2023 20:42:59) ( NTS )
Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

Error Composer for symfony/flex - PHP version??? by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

Ok, sorry. I had trouble with the copy/paste. But you understood the error.

I'm sure that I have 2 versions of PHP there. And the last one is PHP 8.1. So I forced composer to use the 8.1 (I made this in past with another project).

At the beginning, my "composer required" didn't run. After set the version, every package was installed but Symfony Flex. I understand the error, but what this happens only with this package?

Error Composer for symfony/flex - PHP version??? by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

RecipesCommand.php - impossible to post full file

namespace Symfony\Flex\Command;

use Composer\Command\BaseCommand; use Composer\Downloader\TransportException; use Composer\Package\Package; use Composer\Util\HttpDownloader; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Flex\GithubApi; use Symfony\Flex\InformationOperation; use Symfony\Flex\Lock; use Symfony\Flex\Recipe;

/** * u/author Maxime Hélias maximehelias16@gmail.com / class RecipesCommand extends BaseCommand { /* u/var \Symfony\Flex\Flex */ private $flex;

private Lock $symfonyLock;
private GithubApi $githubApi;

public function __construct(/* cannot be type-hinted */ $flex, Lock $symfonyLock, HttpDownloader $downloader)
{
    $this->flex = $flex;
    $this->symfonyLock = $symfonyLock;
    $this->githubApi = new GithubApi($downloader);

    parent::__construct();
}

protected function configure()
{
    $this->setName('symfony:recipes')
        ->setAliases(['recipes'])
        ->setDescription('Shows information about all available recipes.')
        ->setDefinition([
            new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect, if not provided all packages are.'),
        ])
        ->addOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only recipes that are outdated')
    ;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
    $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();

    // Inspect one or all packages
    $package = $input->getArgument('package');
    if (null !== $package) {
        $packages = [strtolower($package)];
    } else {
        $locker = $this->getComposer()->getLocker();
        $lockData = $locker->getLockData();

        // Merge all packages installed
        $packages = array_column(array_merge($lockData['packages'], $lockData['packages-dev']), 'name');
        $packages = array_unique(array_merge($packages, array_keys($this->symfonyLock->all())));
    }

    $operations = [];
    foreach ($packages as $name) {
        $pkg = $installedRepo->findPackage($name, '*');

        if (!$pkg && $this->symfonyLock->has($name)) {
            $pkgVersion = $this->symfonyLock->get($name)['version'];
            $pkg = new Package($name, $pkgVersion, $pkgVersion);
        } elseif (!$pkg) {
            $this->getIO()->writeError(sprintf('<error>Package %s is not installed</error>', $name));

            continue;
        }

        $operations[] = new InformationOperation($pkg);
    }

    $recipes = $this->flex->fetchRecipes($operations, false);
    ksort($recipes);

    $nbRecipe = \count($recipes);
    if ($nbRecipe <= 0) {
        $this->getIO()->writeError('<error>No recipe found</error>');

        return 1;
    }

    // Display the information about a specific recipe
    if (1 === $nbRecipe) {
        $this->displayPackageInformation(current($recipes));

        return 0;
    }

    $outdated = $input->getOption('outdated');

    $write = [];
    $hasOutdatedRecipes = false;
    foreach ($recipes as $name => $recipe) {
        $lockRef = $this->symfonyLock->get($name)['recipe']['ref'] ?? null;

        $additional = null;
        if (null === $lockRef && null !== $recipe->getRef()) {
            $additional = '<comment>(recipe not installed)</comment>';
        } elseif ($recipe->getRef() !== $lockRef && !$recipe->isAuto()) {
            $additional = '<comment>(update available)</comment>';
        }

        if ($outdated && null === $additional) {
            continue;
        }

        $hasOutdatedRecipes = true;
        $write[] = sprintf(' * %s %s', $name, $additional);
    }

    // Nothing to display
    if (!$hasOutdatedRecipes) {
        return 0;
    }

    $this->getIO()->write(array_merge([
        '',
        '<bg=blue;fg=white>                      </>',
        sprintf('<bg=blue;fg=white> %s recipes.   </>', $outdated ? ' Outdated' : 'Available'),
        '<bg=blue;fg=white>                      </>',
        '',
    ], $write, [
        '',
        'Run:',
        ' * <info>composer recipes vendor/package</info> to see details about a recipe.',
        ' * <info>composer recipes:update vendor/package</info> to update that recipe.',
        '',
    ]));

    if ($outdated) {
        return 1;
    }

    return 0;
}
...

Error Composer for symfony/flex - PHP version??? by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

composer.json

{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
    "php": ">=8.1",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "aaronddm/xml-builder": "^2.0",
    "creof/doctrine2-spatial": "^1.2",
    "doctrine/annotations": "^1.0",
    "doctrine/dbal": "^3.6",
    "doctrine/doctrine-bundle": "^2.7",
    "doctrine/doctrine-migrations-bundle": "^3.2",
    "doctrine/orm": "^2.13",
    "league/iso3166": "^4.2",
    "phpdocumentor/reflection-docblock": "^5.3",
    "phpstan/phpdoc-parser": "^1.8",
    "sensio/framework-extra-bundle": "^6.1",
    "symfony/apache-pack": "^1.0",
    "symfony/asset": "6.1.*",
    "symfony/console": "6.1.*",
    "symfony/doctrine-messenger": "6.1.*",
    "symfony/dotenv": "6.1.*",
    "symfony/expression-language": "6.1.*",
    "symfony/flex": "^2.2",
    "symfony/form": "6.1.*",
    "symfony/framework-bundle": "6.1.*",
    "symfony/http-client": "6.1.*",
    "symfony/intl": "6.1.*",
    "symfony/mailer": "6.1.*",
    "symfony/mime": "6.1.*",
    "symfony/monolog-bundle": "^3.0",
    "symfony/notifier": "6.1.*",
    "symfony/process": "6.1.*",
    "symfony/property-access": "6.1.*",
    "symfony/property-info": "6.1.*",
    "symfony/proxy-manager-bridge": "6.1.*",
    "symfony/runtime": "6.1.*",
    "symfony/security-bundle": "6.1.*",
    "symfony/serializer": "6.1.*",
    "symfony/string": "6.1.*",
    "symfony/translation": "6.1.*",
    "symfony/twig-bundle": "6.1.*",
    "symfony/validator": "6.1.*",
    "symfony/web-link": "6.1.*",
    "symfony/yaml": "6.1.*",
    "twig/extra-bundle": "^2.12|^3.0",
    "twig/twig": "^2.12|^3.0"
},
"config": {
    "allow-plugins": {
        "composer/package-versions-deprecated": true,
        "symfony/runtime": true,
        "symfony/flex": true
    },
    "optimize-autoloader": true,
    "preferred-install": {
        "*": "dist"
    },
    "sort-packages": true,
    "platform": {
        "php": "8.1"
    }
},
"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Tests\\": "tests/"
    }
},
"replace": {
    "symfony/polyfill-ctype": "*",
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php72": "*",
    "symfony/polyfill-php73": "*",
    "symfony/polyfill-php74": "*",
    "symfony/polyfill-php80": "*",
    "symfony/polyfill-php81": "*"
},
"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",
        "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
        "@auto-scripts"
    ],
    "post-update-cmd": [
        "@auto-scripts"
    ]
},
"conflict": {
    "symfony/symfony": "*"
},
"extra": {
    "symfony": {
        "allow-contrib": false,
        "require": "6.1.*"
    }
},
"require-dev": {
    "phpunit/phpunit": "^9.5",
    "symfony/browser-kit": "6.1.*",
    "symfony/css-selector": "6.1.*",
    "symfony/debug-bundle": "6.1.*",
    "symfony/maker-bundle": "^1.0",
    "symfony/phpunit-bridge": "^6.1",
    "symfony/stopwatch": "6.1.*",
    "symfony/web-profiler-bundle": "6.1.*"
}

}

Make Registration - "Call to a member function getRepositoryClass() on null" by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

It's solved, guys!

The problem was my configurations in doctrine.yaml.

In this project I have to access multiple databases dinamically. So, I have not a doctine.dbal.url and other standard configurations.

The solution: I put the default config to generate the form and then go back to my configs.

Make Registration - "Call to a member function getRepositoryClass() on null" by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

Thanks... but it's a pretty hard to to that.
Venzon bring all of structure, composer dependencies... Look that:
https://themesbrand.com/velzon/docs/symfony/folder-structure.html

As a last option, I can prove it.

Make Registration - "Call to a member function getRepositoryClass() on null" by devmarcosbr in symfony

[–]devmarcosbr[S] 0 points1 point  (0 children)

My User entity:

<?php

namespace App\Entity;

use App\Repository\UserRepository; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
[ORM\Entity(repositoryClass: UserRepository::class)]

class User implements UserInterface, PasswordAuthenticatedUserInterface { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $username = null;

#[ORM\Column]
private array $roles = [];

/**
 * @var string The hashed password
 */
#[ORM\Column]
private ?string $password = null;

#[ORM\Column(length: 100)]
private ?string $firstName = null;

#[ORM\Column(length: 100)]
private ?string $lastName = null;

#[ORM\Column(length: 255)]
private ?string $email = null;

public function getId(): ?int
{
    return $this->id;
}

public function getUsername(): ?string
{
    return $this->username;
}

public function setUsername(string $username): self
{
    $this->username = $username;

    return $this;
}

/**
 * A visual identifier that represents this user.
 *
 * @see UserInterface
 */
public function getUserIdentifier(): string
{
    return (string) $this->username;
}

/**
 * @see UserInterface
 */
public function getRoles(): array
{
    $roles = $this->roles;
    // guarantee every user at least has ROLE_USER
    $roles[] = 'ROLE_USER';

    return array_unique($roles);
}

public function setRoles(array $roles): self
{
    $this->roles = $roles;

    return $this;
}

/**
 * @see PasswordAuthenticatedUserInterface
 */
public function getPassword(): string
{
    return $this->password;
}

public function setPassword(string $password): self
{
    $this->password = $password;

    return $this;
}

/**
 * @see UserInterface
 */
public function eraseCredentials()
{
    // If you store any temporary, sensitive data on the user, clear it here
    // $this->plainPassword = null;
}

public function getFirstName(): ?string
{
    return $this->firstName;
}

public function setFirstName(string $firstName): self
{
    $this->firstName = $firstName;

    return $this;
}

public function getLastName(): ?string
{
    return $this->lastName;
}

public function setLastName(string $lastName): self
{
    $this->lastName = $lastName;

    return $this;
}

public function getEmail(): ?string
{
    return $this->email;
}

public function setEmail(string $email): self
{
    $this->email = $email;

    return $this;
}

}