-
-
Notifications
You must be signed in to change notification settings - Fork 282
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a Component errors #1039
Comments
Documentation about factories is quite clear. First it shows how to create factory yourself, then it says you can instead just write interface and Nette will implement the class itself. Directory structure is quite irelevant here - you either place it wherever you want in app directory (in app/Bootstrap.php from nette/web-project is configured robotloader, which will just load them) or follow commonly accepted PSR-4 convention and setup PSR-4 autoloading via Composer. |
Nobody gets everything on the first try. Have you tried asking on https://forum.nette.org? |
Hi Kashan
I followed your steps, making the directories and files you said. I'm glad you also provided images.
Again I ran into problems. So created a fresh project and used the same name as yours.
Then I re-read the Nette docs and using your information along side, I was able to get my template to show.
So I got over the big first step, now I must try to make it do complex things... But it took much time...
Thanks for your support
… On Jan 26, 2024, at 2:17 PM, Kashan Ahmad ***@***.***> wrote:
Hi, I'm new to Nette as well and just recently figured out how to make the component factories work, here it goes:
Create a directory called Factories and place your component factory files inside:
image.png (view on web) <https://github.com/nette/docs/assets/104863696/b60929b5-9150-4766-8406-6cb752868bae>
Next up, use the shorthand mentioned by the docs in the factory instead of instantiating the component yourself:
image.png (view on web) <https://github.com/nette/docs/assets/104863696/8b2de0aa-f5bc-47bb-a4b4-2631ac79d0ac>
Once done, use the factory in your presenter's createComponent method and pass params if necessary:
image.png (view on web) <https://github.com/nette/docs/assets/104863696/f3de1284-885a-4ae6-9ceb-59fa1895465b>
Finally, add the factory to the DI container using the services.neon file and you'll be good to go:
image.png (view on web) <https://github.com/nette/docs/assets/104863696/173033c2-895f-432c-a6f7-9a38e956cb83>
I do believe the docs are severely lacking and the deeper you get into the framework the harder it becomes for a newbie, I spent 4 hours yesterday trying to work around flashMessages, I'm using a monorepo of multiple nette applications instantiated from a core PHP application and it works like a charm, just not that easy.
I wish they could make the docs more beginner friendly, the framework is awesome.
—
Reply to this email directly, view it on GitHub <#1039 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ADGGEH5O5EN5LJSJINXPRWTYQP6LPAVCNFSM6AAAAABCLMNCFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJSGU3DKNRQGQ>.
You are receiving this because you authored the thread.
|
URL: https://doc.nette.org/en/application/components
I tried to follow the steps on this page, to make a component. But there's problems.
It said to create a Factory then it says create an Interface. Both have the same name. One could put them into separate directories, files can be created with the same names.
Please explain with a directory structure.
Nette is great and makes a complex task, simple. But I think the documentation is lacking. I mean it probably make perfect sense to a experienced Nette programmers. However people like me that are new-commers cannot piece things properly. After reading and reading many parts of the documentation, I still have problems getting Latte templates correct.
Please provide a simple example.
The text was updated successfully, but these errors were encountered: