D
D
Dmitry2014-01-27 10:30:10
Yii
Dmitry, 2014-01-27 10:30:10

I'm learning Yii, have some general questions that I can't find answers to myself?

I am currently studying YII. A few years before that, he worked with his self-written engine. Finally, I decided to move away from bydlokoderstva and try to start working with a normal framework.
This is my first experience with any kind of framework, so at the beginning, even the very concept of Framework was difficult for me.
In the process of studying, several questions arose, the answers to which I have not yet found, and I would like to ask them to those who work with Yii and understand this framework.
1. The controller->action system works on the principle that the URL contains the parameter r=site/page where site is the name of the controller, page is the name of the action in this controller. I'm interested in this question: it turns out that the structure of the URL will always obey this rule, that there should be two parameters (controller and action), or one (controller)? I don't count additional parameters that can be added, such as any filters, page numbers, etc. For example, there is a directory on the site mysite.ru/catalog - a page with a list of catalog sections (catalog is a controller that calls the default action that displays a list of catalog subsections on the page). But if, say, we went to some section (for example, kitchen appliances), then I want my URL to have the following structure mysite.ru/catalogue/kitchen, and further, if in kitchen appliances we went to the microwave section, then URL: mysite.ru/catalogue/kitchen/microwave. And in this case, I no longer understand what is the controller, what is the action, etc. Are such URLs allowed? Or, when developing on Yii, I have to do something like this: mysite.ru/index.php?r=catalogue/view&category=microwaves (i.e. the "catalog" controller, the "display a list of products" action and the additional category parameter, which points to the desired section of the goods)? In short, the essence of my question is, does Yii give you the ability to freely work with URLs, i.e. design their structure as the programmer or client wishes, or the URL must obey some strict rules. I know that the "r=site/page" format can be turned into a CNC like /site/page, but this is again a rigid structure, the /controller/action pair.
2. Development of the backend or, more simply, the "admin panel" of the site. In Yii, using GII, you can create CRUD operations and a simple admin form. That is, roughly speaking, on the basis of an existing table in the database, you can automatically create a simple admin panel, with which you can add, delete and edit records in this database.
If I make my own admin panel, with my own design, with my own functionality, should I create it from scratch, having the entire arsenal of Yii development tools, or should I make it based on these automatically created CRUDs? For example, I want my admin panel to be loaded at mysite.ru/admin, have an authorization form, and then a convenient panel for working with it, etc.
3. I searched on the Internet, but I did not find a more detailed description of the framework's work. Those. the general principle is described everywhere: a request from the client enters index.php, then the main controller is called, it calls .... etc. Schemes are drawn, the principle of MVC is described. But I would like to see all this at a lower level. Those. specifically: here is index.php, here is the controller call function, etc. Those. just like in debug mode, go through all the stages of the framework, if not line by line, but at least in the order of function calls (here, a request was received to the index, then the URL parsing function was called, then this data was received by the controller function, the controller, in turn, called this, that and that ... etc.). Is it possible to read about it somewhere, or can I configure the debugging functionality on my machine and run it in debug mode,

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey, 2014-01-27
Protko @Fesor

there is an official forum for such questions, there is even a Russian-language branch there.
1) concerning routing - is not present. Routes are essentially a binding of a specific url to a specific action, sculpt them however you want, everything can be resolved in the code. The fact that the documentation and examples are flawed everywhere is a community problem.
2) As you wish, you can customize your templates for gii and generate everything purely for yourself, you can generate and resaw, you can not use it at all.
3) go to the cwebapplication class and see. There is no architecture as such, everything is as simple as two fingers. If you want to understand the architecture from below, see the framework code.

K
Kola, 2014-02-14
@LDZ

1. Urls are configured in the most detailed way as you need.
Read about url manager rules. Including about parametrization of urls.
The same URL mysite.ru/catalogue/kitchen/microwave you specified can be written as such a route
Then the view action of the catalog controller will be called, into which the catname and subcatname parameters will be passed to GET
.
2. To create an admin panel, there are both separate modules and the possibility of separating the frontdoor and backdoor. This has been described in detail on the forum. Look
3. What prevents you from seeing which method is called in index.php and following the entire chain of calls?

A
Alexander Urich, 2015-04-03
@Urichalex

Questions 1 and 2 are modules. The catalog module in it is the kitchen module in it, for example, the controller is microwaves, and there are already view and index, etc. The same with the admin. I make a separate module in all my projects for the admin panel, and there are controllers in it for what I need.
3. stupidly go and look at the code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question