18.
MakerBundle
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
20 Comments
Getting this error:
"Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires symfony/maker-bundle ^1.43 -> satisfiable by symfony/maker-bundle[v1.43.0].
- symfony/maker-bundle v1.43.0 requires symfony/config ^5.4.7|^6.0 -> found symfony/config[v5.4.7, v5.4.8, v5.4.9, v6.0.0, ..., v6.1.0] but the package is fixed to v4.4.41 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require symfony/maker-bundle:*" to figure out if any version is installable, or "composer require symfony/maker-bundle:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content."
Hey Guilherme,
Yeah, looks like the latest MakerBundle version requires a newer Symfony version that installed in the course code - we use Symfony 4.0 there. Try to limit MakerBundle to ^1.35 at least, i.e. run this command instead:
$ composer require "maker:^1.35"
This should install the Maker, though not the latest version of it. For the latest version you would need to upgrade installed Symfony packages first. But 1.35 version of maker is totally fine for this tutorial - on the time we record this tutorial - we used v1.0.2 :)
Cheers!
I installed with $ compose require maker:* (it installs the latest "possible" version right?) it installed v1.39, it's working so I guess it's fine? Is it a good practice to use the wildcard package:* in this situations where you have locked versions of dependencies? (feel free to correct anything I said, I'm learning). Thank you for your answer my friend!
Hey Guilherme,
If that * worked for you - great! You probably have a bit fresher Symfony version than we do in the course code. About using it every time - I'd not recommend this. You should just execute "composer require maker" and if it failed because of some incompatibility - try that * wildcard then. But better, look at the error message and try to figure out why exactly it's failing.
I hope this helps!
Cheers!
Hi,
before starting the Forms course I would like to understand how to get hearts with the best practise 'Getting Services from the Service Container'.
I suppose that I have to create a service in directory service and then using EntityManagerInterface to get hearts number. Is this the right way?
Thanks for your help.
Hey Gaetano S.
You can create an
EntityRepositorythat will encapsulate the query logic for fetching the total hearts. Then in a controller you can just inject that repository and use it. Or, if you want to have a layer between your repositories and controllers, then you can create a service class that will call the repository for youCheers!
Hello again :),
what do yo think about this way?
And then I inject this service in ArticleStatsCommand.
Thanks a lot for your advice.
`
namespace App\Service;
use App\Entity\Article;
use Doctrine\ORM\EntityManagerInterface;
class HeartHelper
{
}
`
That's not bad but I have a couple of tips :)
1) Since Symfony4 you can inject Repositories, you don't have to get them through the EntityManager (Although you still can)
2) You need to check that the
$articlewas found, in other words, it's not null because you are fetching by slug field, it may not existCheers!
ok, now I understand better. Inside the function execute of my articlestatscommand I inject ArticleRepository and I call my Articlerepository method .
This is my function inside ArticleRepository:
`
public function getHeartNumberBySlug($slug) {
`
Thanks for your help.
As I am watching it, the maker can now create the entire CRUD for Doctrine Entity. Time to say goodbye to CakePHP.
Hey Michal S. ,
Yay, our friend Vladimir contributed that! https://symfony.com/blog/ne...
But did you wait only for CRUD generator so far before saying goodbye to CakePHP? It looks like the most wanted feature for you :p
Cheers!
CRUD generator IS one of the CakePHP's amazing superpowers Symfony lacked. To be completely honest, it is still difficult to say goodbye to CakePHP, as it is soooooo intuitive thanks to the convention over configuration approach, like not having to call neither the entity manager nor the template but still having them was amazing.
Having said that, Symfony feels much less like a great toy but more like a mature tool which makes it a go-to choice as the projects become more advanced. In short, I absolutely love Symfony, but leaving CakePHP does feel a lot like an actual break-up. And getting options such as CRUD generator just makes the transition easier. So while it is not the deal-breaker, it helps to get in Symfony what I had in Cake (aside from the Symfony-specific features like autowiring which is CRAZY in a good way).
Also, a shout out to Vladimir - you are the man!
Hey Michal S.
Thanks for the good words! I'm appreciate that you liked CRUD generator.
BTW I always wondered if someone use it :p
Cheers!
Hey Michal S. ,
I think it's just more matter of habit, if you get used to something, other workflows may seem weird at the first sight, though I have never used CakePHP so it's difficult to compare for me :) Anyway, Symfony is getting much more thin with the new Symfony Flex, that's a crazy cool. ;)
Cheers!
Wouldn't it make sense to install maker bundle via --dev flag? Because we only need to create files with make: in dev env?
Hey Mika,
Yes, Ryan just missed it. We totally should install Maker for dev only... and we've already fixed it in scripts and added a note in the video.
Cheers!
A quick note for those who may be using Windows10 PowerShell ISE.
For whatver reason, it appears, at least on my system, that while in the ISE,the make:command doesn't execute properly and leaves you hanging at the "Choose a command name (e.g. app:some-thing):" prompt without allowing you to enter the command name.
The good news, if you use the standalone PowerShell, this is not an issue.
Hey Raymond,
Thanks for this notice. I personally haven't heard about this problem before. It makes sense to upgrade to the latest version of MakerBundle. If you still have this issue, feel free to open a bug in its repo with detailed steps to reproduce.
Cheers!
I'm honestly not sure if this is a problem wiht MakerBundle, or with PowerShell ISE. I'm more inclined to blame ISE as it is working fine in a standalone PowerShell window
Yeah, probably so. Not sure what can you do then, probably that PowerShell ISE has some kind of configuration where this can be fixed, do not know :/
"Houston: no signs of life"
Start the conversation!