yiisoft / docs Goto Github PK
View Code? Open in Web Editor NEWVarious Yii 3.0 related documentation
Home Page: http://www.yiiframework.com
License: BSD 3-Clause "New" or "Revised" License
Various Yii 3.0 related documentation
Home Page: http://www.yiiframework.com
License: BSD 3-Clause "New" or "Revised" License
The idea is to describe useful patterns that allow structuring code with Yii 3 examples.
What is the fully qualified name of the class Controller
in this example in https://github.com/yiisoft/docs/blob/master/guide/en/structure/middleware.md?
$authorizedAction = new Controller(SiteController::class, 'auth', $container);
I always wanted to translate Yii to Kiswahili Community. but I postponed due to announcement of the advent of Yii3. So This will serve as tracker for my progress on translating Guides and then API to Kiswahili.
Databses section is really a stub. No mention of Yii2 AR/DAL, nor there is recommended way of handlind data layer with Repos.
App\ViewRenderer
You should be able to use this to render any view file
Yiisoft\Factory\Exception\NotFoundException
No definition or class found for "No definition or class found for "App\ViewRenderer".".
Q | A |
---|---|
Version | 1.0.? |
PHP version | 8.0.9 |
Operating system | OS X Big Sur |
I have studied yiisoft/docs, but I still can't make yiisoft/app work in swoole, could it add the entry script of swoole and roadrunner to this project ?
hi,
Could you add yii3 tag for related repos?
When is the document expected to be completed
And
What is the current stage of Yii3
See Composer docs.
Could be added to performance section.
@yii3ru
/ @yii3en
in TelegramPSR Naming Conventions says:
Abstract classes MUST be prefixed by Abstract: e.g. Psr\Foo\AbstractBar.
I think we need to fix it in the same way as interface naming conventions is fixed
See PHP-CS-Fixer/PHP-CS-Fixer#3048
I suggest always add \
to functions from this post PHP-CS-Fixer/PHP-CS-Fixer#3048 (comment)
I setup a boilerplace to build a minimal version of Yii3 for a project. See the composer.json
{
"minimum-stability": "dev",
"require": {
"php": ">=7.2.0",
"yiisoft/yii-web": "^3.0@dev",
"yiisoft/di": "^3.0@dev",
"yiisoft/log": "^3.0@dev",
"yiisoft/cache": "^3.0@dev"
}
}
I should be able to install dependencies.
I receive the following message:
Problem 1
- Installation request for yiisoft/yii-web ^3.0@dev -> satisfiable by yiisoft/yii-web[3.0.x-dev].
- yiisoft/yii-web 3.0.x-dev requires psr/http-factory-implementation 1.0 -> no matching package found.
Q | A |
---|---|
Version | 3.0 |
PHP version | 7.3.9 |
Operating system | macOS Catalina |
Add the following to the URL group or route you need to remove CSRF protection from:
->disableMiddleware(CsrfMiddleware::class)
Need to document #11328
Here need info about keys in params.php
.
In yii-cycle and yii-console use vendor/package-name
.
In aliases use simple package-name
.
It is better to use the same approach in all packages.
I think better always use key vendor/package-name
and nested array with params. For example:
return [
'yiisoft/aliases' => [
'aliases' => [],
],
];
$this->app (it is not available in the models).
That is available and not using Yii: getApp () which is deprecated en Yii 3.0, remember that in Yii2, Yii::$app was available everywhere.
Of course you can go through the constructor $ this-> app to the model, but it would be cleaner if it were available by default, as in the controllers and views, and thus the use of the new commands is encouraged.
Commands in models for example:
$this->app->t
$this->app->user->login
$this->app->params
$this->app->security
Q | A |
---|---|
Yii version | 3.0 |
PHP version | 7.1.23 |
Operating system | Centos 7.0 |
What is the best practice to use a dependency (defined in config) ?
I'd expect to have it from constructor, but other parameters are passed in it.
class CustomController extends \yii\web\Controller
{
public function __construct(\yii\authclient\clients\GitHub $githubClient)
{
}
}
So I've solved using:
Yii::getApp()->container->get(\yii\authclient\clients\GitHub::class)
Is this last the right and suggested approach?
I have not found such a controller in the source code.
And in the example it is not.
vendor\bin\yii
- note the backslash.php
should be in your PATH (describe or link to how to set up env variables).Hi, I'm starting to use yii 3.0 to make some proof of concept and to learn new features from Yii3.0 before it is released.
I have a question about all the config files created in yiisoft/yii-core
and other libraries/modules:
The use of https://github.com/hiqdev/composer-config-plugin is really great but I don't understand why some parameters are defined in https://github.com/yiisoft/yii-core/blob/master/config/params.php and used in https://github.com/yiisoft/yii-core/blob/master/config/common.php#L27.
This force the final developper to override keys defined in https://github.com/yiisoft/yii-core/blob/master/config/params.php in its own params.php
file which will be cluttered.
I don't think it's a good idea as those values are already hardcoded in yiisoft/yii-core
For example
right now we have :
https://github.com/yiisoft/yii-core/blob/master/config/params.php
return [
'app.id' => 'core',
'app.name' => 'Core',
'app.language' => 'en',
];
and in https://github.com/yiisoft/yii-core/blob/master/config/common.php
...
'app' => [
'id' => $params['app.id'],
'name' => $params['app.name'],
'language' => $params['app.language'],
'aliases' => array_merge($aliases, [
'@root' => YII_ROOT,
'@vendor' => '@root/vendor',
'@public' => '@root/public',
'@runtime' => '@root/runtime',
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
]),
'params' => $params,
],
...
Why do not leave https://github.com/yiisoft/yii-core/blob/master/config/params.php empty
return [
];
and define hardcoded values in https://github.com/yiisoft/yii-core/blob/master/config/common.php
...
'app' => [
'id' => 'core',
'name' => 'Core',
'language' => 'en',
'aliases' => array_merge($aliases, [
'@root' => YII_ROOT,
'@vendor' => '@root/vendor',
'@public' => '@root/public',
'@runtime' => '@root/runtime',
'@bower' => '@vendor/bower-asset',
'@npm' => '@vendor/npm-asset',
]),
'params' => $params,
],
...
This way, app configuration will be done by the developper as it was before :
in app/params.php
return [
'myparam1' => 'value1',
];
and app/common.php
return [
'app' => [
'id' => 'my-app',
'name' => 'My own Application',
'language' => 'fr',
],
]
and this will leave params.php
dedicated to application parameters which will be more clear.
Assuming that you're using PHP 8.x with IIS 10.0:
Run composer on command prompt (admin)
Run "cd c:\inetput\wwwroot\projects" (this is my main folder)
Run "composer create-project --prefer-dist --stability=dev yiisoft/app basic"
On IIS, expand the Default Web Site -> projects and right click on this folder "Add virtual directory"
On the alias, type "yii3basic" and folder "C:\inetpub\wwwroot\projects\basic\public".
In IIS, click once on "yii3basic" folder, and select PHP Manager. Make sure it's selected PHP 8.x, and the extensions "fileinfo" and "pdo sqlite" are enabled
Open the browser and navigate to http://localhost/projects/yii3basic
If the framework shows any warning about runtime folder, make sure the folders have sufficient permissions
Navigate to the landing page (index)
A 404 error: The page /projects/yii3basic/ not found.
Q | A |
---|---|
Version | dev-master |
PHP version | 8.0.10 |
Operating system | Windows 10 |
Design for configuration rebuild is now (as of 2020-11-12):
This is important differences that should be noted somewhere in docs, "Configuration", "Deployment" or "Installation" section.
how a good design of the DI could be done with multiple domains/modules/packages?
(E.g. where you suggest putting interfaces to connect these things later on.)
Hi Yii Team,
I really like Yii1/2 which is enable people to build traditional web application easily and robust.
We have plenty of widgets (or Kartik extensions) which were well designed and can use out of box.
SPA is more and more popular in these days. There are different approaches by different framework, such as .Net use Blazor.
Or GoLang use REST+Frontend, or some people create "gin-vue-admin" to try auto generate code to easy the developments. (Some kind like Yii Gii).
The strength of Yii framework is help user to both write frontend & backend code at same framework with high productivity, the feeling is good. Or else, if we have to split as 2 set, then people have lots of other choices, such as use Go/.Net/Java for backend, and Vue(Quasar framework look good)/React/Angular for frontend. As you know PHP speed is slow from backend perspective, the conveniences are the most attracting features.
Do Yii3 plan provide SPA turn key solutions? Such as leverage Vue or React or jQuery/AJAX or whatever to enable users build single page application easily just like before we build traditional web with widgets?
Thanks for your consideration and support in advance.
Regards,
Scott Huang
"src/Controller/Echo.php"
should read
"src/Controller/EchoController.php"
Just a suggestion: Instead of 'Echo' use 'Hello' or 'Greeting', which would enable reader to easily create the 'Form' guide without rewriting the files from that example.
Otherwise, description works well for me
Mike B
https://github.com/yiisoft/yii2/blob/master/build/controllers/TranslationController.php could be ported as a tool to aid translation process.
When to use provider and when to use container config directly?
See yiisoft/di#211
I want install Yii 3
to test. Clone repository and start command composer install
in root folder. Console return this error:
[Foxy\Exception\RuntimeException]
No asset manager is found
Index page display this:
Warning: require_once(/var/www/public/intnature/vendor/autoload.php): failed to open stream: No such file or directory in /var/www/public/intnature/public/index.php on line 11
Fatal error: require_once(): Failed opening required '/var/www/public/intnature/vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/public/intnature/public/index.php on line 11
How I can fix it?
Thank you.
https://github.com/yiisoft/docs/blob/master/guide/en/intro/upgrade-from-v2.md could be enhanced:
I realise documentation is not complete and yii3 is still in development. I am just trying to plan a migration from yii2 to yii3 and the only thing I cannot seem to work from this project is where I stick my "models"
Apologies if this is a stupid question. Very much have my Yii2 hat on.
Is there a recommended directory structure?
I can do the configuration guide for doctrine:
Thks,
Q | A |
---|---|
Version | 3.0. |
PHP version | 7.3.23 |
Operating system | Windows 10 |
Доброго дня. Т.к. свой новый корпоративный проект я решил сразу начать на yii3, то возник ряд вопросов/непониманий. Относятся они наверно ко всему yii3, но живой кейс возник с виджетом табов, поэтому напишу сюда.
Итак имеем:
Мой "живой" случай в идеале, но не как сейчас:
$tabs = Tabs::widget();
//Ставим остальные свойства через сеттер
$this->registerJs('Vue.createApp(SourceTabsOptions).mount("#' . $tabs->options['id'] . '");');
Т.е. мне всё-равно какой id сгенерится виджетом, у меня к нему не привязано никаких CSS, ни чего другого. Но сейчас я вынужден каждый раз выдумывать этот самый id элемента, т.к. не могу получить приватный $options
Вопрос - а почему эти свойства не сделать публичными?
При этом, если допустить ошибку и забыть при конфигурации указать "()" в конце, то yii3 заботливо предлагает добавить "$" в начало, чтобы установить свойство - что опять-же не работает с приватными свойствами. Но как минимум я так полагаю, что задумка такая была, но сейчас я мало где вижу ей применение, т.к. практически всё либо private, либо в лучшем случае protected
Заранее благодарен
We aren't including our own implementation for now so we can demo on how to use latest Guzzle instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.