yiisoft / app Goto Github PK
View Code? Open in Web Editor NEWYii3 application template
Home Page: https://www.yiiframework.com/
License: BSD 3-Clause "New" or "Revised" License
Yii3 application template
Home Page: https://www.yiiframework.com/
License: BSD 3-Clause "New" or "Revised" License
The following parts could be removed from the template (more to be added):
I just ran composer create-project --prefer-dist --stability=dev yiisoft/app app
And then composer run serve
Start development webserver
PHP Fatal error: Uncaught Yiisoft\Factory\Exceptions\NotFoundException: No definition for Psr\EventDispatcher\EventDispatcherInterface in <removed>/vendor/yiisoft/di/src/Container.php:222
Unsure what about my system setup is wrong here, couldnt find anything regarding this on google or obvious packages I needed to install. What am I missing?
Q | A |
---|---|
Version | 1.0.? |
PHP version | 7.4.11 |
Operating system | Ubuntu 20.04 |
Provide some useful links:
This is may be useful for CI.
Exception: Route should be either an instance of Route or Group, array given.
change of the file app/config/routes.php:
declare(strict_types=1);
use App\Controller\SiteController;
use Yiisoft\Router\Route;
use \Yiisoft\Router\Group;
return [
Route::get('/')->action([SiteController::class, 'index'])->name('home'),
**Group::create('/api')
->middleware(ApiAuthentication::class)
->host('https://example.com')
->routes([
Route::get('/comments'),
])**
];
Q | A |
---|---|
Version | 1.0.? |
PHP version 8 | |
Operating system |
runtime
and public/assets
should be writeable.
Try change https://github.com/yiisoft/app/blob/master/config/params.php#L22 to
/projects/yii3basic/assets
.
i think this value should be prefixed with @baseUrl
: '@baseUrl/assets'
The @baseUrl
alias will be changed automatically in the SubFolder middleware
Originally posted by @roxblnfk in https://github.com/yiisoft/app/issues/196#issuecomment-934737198
See vlucas/phpdotenv#207 (comment)
Main motivation is performance.
We should try to implement Twig templates in the app.
Main benefit is that it provides output escaping out of the box so there will be way less Yii 3 apps with XSS. Another thing is that it's a good idea to try using Twig with widgets and classes we have.
Instead of grouping project files by type, we should group them by "use cases" or "modules".
Old structure (typical for Yii2), grouping by type:
/src/Controllers/Module1/Module1Controller
/src/Controllers/Module2/Module2Controller
/src/Components/Module1/Component1
/src/Components/Module2/Component2
/views/module1/index
/views/module2/index
/tests/module1/Testcase
/tests/module2/Testcase
New refined modern structure with grouping by module:
/src/Module1/
Controllers/Module1Controller
Components/Component1
Views/index
Tests/Testcase
/src/Module2/
Controllers/Module2Controller
Components/Component2
Views/index
Tests/Testcase
1 module = 1 folder
Not only classes should be grouped by modules, but views and tests too.
Benefits:
Store in one place all that is used in one business feature. For example, code with tests that testing it. Easy to find, easy to manage.
Reuse module between projects with copy-paste module folder. Easy!
Fork modules to reuse in same project. Just copy that folder, and replace some logic.
Work in single folder at one time, tinkering some feature. No need to open 3-4 folders in project tree (code, tests, views, etc).
When installing using composer, it's shows
- Installing foxy/foxy (v1.1.0): Loading from cache
Plugin installation failed, rolling back
- Removing foxy/foxy (v1.1.0)
[Foxy\Exception\RuntimeException]
No asset manager is found
We can use functional tests only and remove any acceptance ones.
Clean install with composer create-project --prefer-dist --stability=dev yiisoft/app <app_name>
and composer run serve
Debugger is enabled in params file
'yiisoft/yii-debug' => [
'enabled' => true
],
Access the index page with debugger enabled
No debug panel is visible
Q | A |
---|---|
Version | 1.0.x-dev |
PHP version | 7.4.5 |
Operating system | Windows 10 x64 |
Now I'm going to start a new project on yiisoft/app or yiisoft/demo. I don't know if it's suitable at present. I hope you can give me some suggestions
All CI builds fail on master branch
Details: https://github.com/yiisoft/app/pull/138/checks?check_run_id=2066672971
What steps will reproduce the problem?
Where's the old community?
What is the expected result?
Why doesn't anyone come? Old fan leave out?
What do you get instead?
Like a private repo!
modify vendor directory, then
in index.php
`$config = new Config(
new ConfigPaths($rootPath,'config','../vendor'),
);
// Run HTTP application runner
$runner = new HttpApplicationRunner($rootPath, $_ENV['YII_DEBUG'], $_ENV['YII_ENV']);
$runner->withConfig($config)->run();`
throwable: Yiisoft\Di\NotFoundException: No definition or class found or resolvable for "Psr\Log\LoggerInterface" while building "Yiisoft\ErrorHandler\ErrorHandler" -> "Psr\Log\LoggerInterface". in ****\vendor\yiisoft\di\src\Container.php:542
Stack trace:
#0 ****\vendor\yiisoft\di\src\Container.php(503): Yiisoft\Di\Container->buildInternal()
#1 ****\vendor\yiisoft\di\src\Container.php(153): Yiisoft\Di\Container->build()
#2 ****\vendor\yiisoft\yii-runner-http\src\HttpApplicationRunner.php(86): Yiisoft\Di\Container->get()
#3 ****\webroot\app\index.php(48): Yiisoft\Yii\Runner\Http\HttpApplicationRunner->run()
Q | A |
---|---|
Version | 1.0.? |
PHP version | |
Operating system |
For now, if I add new console command to app, I have to rebuild config, to apply changes.
Even on development environment!
This behavior is the least expected and VERY surprising.
I must run composer du
every time I change config... Pain (
How it should be?
Config caching must be an option.
Config caching must be DISABLED by default in development environment.
Config with disabled caching must be loaded from disk, fresh every time the app starts.
User MUST have a choice to enable or disable config caching at any moment.
Option CAN be enabled by default for production environment.
common
→ definitions
web
→ definitions-web
console
→ definitions-console
This is will be more consistently with events
, bootstrap
, providers
, routes
and etc.
Hi,
Thank you for the framework, first impression is good.
But could you add suggestion for necessary packages instead of error like: Class not found? Like it doing codeception when missing some packages.
Overall this mechanism should be maximum simple and controllable if someone will wont to add support for his own package.
That looks a bit too verbose and likely affects overall usability of the framework. Is there a way to avoid it?
We do not really need these and can use env variables instead.
I think we should remove the SubFolder
middleware from pipeline.
Its ok for yiisoft/yii-demo
but ok't for yiisoft/app
app/src/Provider/MiddlewareProvider.php
Line 24 in b401b32
Install the app via composer as documented in the readme or the guide.
composer run serve
works.
When pointing the browser to localhost/app/public/
I would expect the same result as running the app through the build in server.
I get a 404 page for the base path (localhost/app/public/)
Q | A |
---|---|
Version | latest |
PHP version | 8.0.3 (MAMP Setup, .htaccess works on other projects) |
Operating system | OS X |
working web page
nothing, just blank (white) page
After addiing in index.php
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
correct error occurs on web page:
PHP Fatal error: Declaration of Yiisoft\Log\Logger::log(mixed $level, Stringable|string $message, array $context = []): void must be compatible with Psr\Log\LoggerTrait::log($level, $message, array $context = [])
If init in console: /dev/app$ ./yii serve '127.0.0.1:8080', you can see the error directly in console. But if via browser, there is no clue that there is an error.
Q | A |
---|---|
Version | master |
PHP version | 8.0.16 |
Operating system | 5.13.0-48-generic # 54~20.04.1-Ubuntu SMP Thu Jun 2 23:37:17 UTC 2022 x86_64 |
Build System | Linux |
PHP Server API | FPM/FastCGI |
Currently layout is broken into _footer.php, _head.php, _menu.php, main.php. Partials aren't reused so merging them into main.php
will make things a little bit simpler.
Now there is a note to not rebuild config in production but there is no method to set environment
It is proposed by SessionMiddleware, CsrfMiddleware, ErrorCatcher to transfer MiddlewareProvider.php to routes.php since the application can have REST API and other APIs for which these Middleware are not required.
When we'll have most of the packages stable, package-lock.json
and composer.lock
should be removed from .gitignore
and committed.
/var/www$ composer create-project --prefer-dist --stability=dev yiisoft/app app
Creating a "yiisoft/app" project at "./app"
Installing yiisoft/app (1.0.x-dev 9b4ba45)
Problem 1
- Root composer.json requires yiisoft/files ^1.0 -> satisfiable by yiisoft/files[1.0.0].
- yiisoft/yii-view dev-master requires yiisoft/csrf ^1.0 -> satisfiable by yiisoft/csrf[1.0.0, 1.0.1, 1.0.2].
- yiisoft/csrf[1.0.0, ..., 1.0.2] require yiisoft/security ^1.0 -> satisfiable by yiisoft/security[1.0.0].
- yiisoft/security 1.0.0 requires yiisoft/strings ^1.0 -> satisfiable by yiisoft/strings[1.0.0, 1.0.1, 1.1.0, 1.2.0].
- You can only install one version of a package, so only one of these can be installed: yiisoft/strings[1.0.0, 1.0.1, 1.1.0, 1.2.0, 2.0.0].
- yiisoft/yii-view 3.0.x-dev is an alias of yiisoft/yii-view dev-master and thus requires it to be installed too.
- yiisoft/files 1.0.0 requires yiisoft/strings ^2.0 -> satisfiable by yiisoft/strings[2.0.0].
- Root composer.json requires yiisoft/yii-view ^3.0@dev -> satisfiable by yiisoft/yii-view[3.0.x-dev (alias of dev-master)].
A console configuration wizard will be great to have. For example:
- Do you want database? Y
- Cycle or DB? DB
- Which server to connect to? localhost
- What is login? root
- What's password? superpassword
will install db package and configure it.
Since there's no sense to start new project with 7.4 when there's stable 8.0, raising minimum requirements for the application templates and demos (but not packages) could be done.
i'm follow the readme.md and tried to test the yii3 and when i'm use "composer run server" show error
> yii serve
sh: yii: command not found
Script yii serve handling the serve event returned with error code 127
I'm looking at the docs on directory structure and I notice that you seem to be going for a structure that's largely based on the type of the content that will go into the folders. For example resources/layout
and resources/view
and src/Controller
and src/Command
.
This is nothing new of course. In fact, most frameworks seem to do this. I've been seeing folder structures like this for 20 years now. Also often seen are public/scripts
, public/images
etc.
So familiar stuff... But best? I'd say no. Not even close.
If I build a new module for some app, say one that deals with uploads, and for that module I need some public assets (icons etc). some controllers, a command etc etc, I end up having to add folders all over the project. Wouldn't it be much nicer if we could have a folder structure based on modules? Where I place all the files related to a module in subfolders of a src/modules
folder? To get a feel for what I mean have a look at this Stack Overflow question that asks about changing from one type of structure to the other and has some nice illustrative screenshots.
Have you guys given this any thought? I've always felt that the structure based on types is very inconvenient and I've also seen that people are never consistent about it. If you check what's inside public/images
for example, sometimes they will have say 'icons' and 'backgrounds' folders in it (consistent), but mostly either directly under images
or otherwise under images/icons
and images/backgrounds
people will almost always switch to a module-based structure. They end up with something like this:
Now if they would be consistent, they would have
...etc, continuing to split up based on the type of content. But people hardly ever do this. I almost always see the switch to module based approach. I reckon they do that because it just becomes ever more unwieldy as you keep doing this. Your code for one module will en up spread out over many different folders.
So why do so many frameworks give us a type-based structure out of the box?
I dare say it's out of convenience for the framework devs and because that's just how it's done in many other frameworks. I understand it's easier to serve all static files from public
, expect all controllers under src/Controller
etc. But again, best for the application / library developer? I say no.
So my question is have you given this much thought and would you consider going a different route here?
composer create-project --prefer-dist --stability=dev yiisoft/app
composer run serve
Fontawesome icons included
<link href="/https://use.fontawesome.com/releases/v5.13.0/css/all.css" rel="stylesheet">
Q | A |
---|---|
Version | dev-master |
PHP version | |
Operating system |
Currently, the routes located in config/routes.php, but that shouldn't be there.
request model become work wrong
public function view(ServerRequestInterface $request): ResponseInterface {
$response = $this->responseFactory->createResponse();
$id = (int)$request->getAttribute('id');
// Here error. Function return null, but before returned value.
// Method GET.
sudo composer create-project --prefer-dist --stability=dev yiisoft/app testYii3
Q | A |
---|---|
Version | 1.0.? |
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS ) | |
Ubuntu 20.04 |
Question 1: How to resolve this one?
Uncaught Yiisoft\Factory\Exception\NotFoundException: No definition or class found for "Psr\Http\Server\RequestHandlerInterface". in /var/www/import/vendor/yiisoft/di/src/Container.php:390
Question 2: Why do we pointing on site
alias in NotFoundHandler.php
?
app/src/Handler/NotFoundHandler.php
Line 28 in 12a104f
We need to use config environments feature and have 2 default set of configs - dev (debug) and prod. Selecting one should be done through YII_ENV environmental variable (or .env).
Same should be applied to all templates and demo apps.
See
The idea is to move some common package params to config/params.php
. For example, db connection, aliases, console controllers list.
CsrfMiddleware is currently running for all requests. However, this functionality is sometimes not required, or a separate implementation is required for individual endpoints that process external requests as API.
Magento has a CsrfAwareActionInterface endpoint interface. If implemented, the endpoint checks the Csrf itself, otherwise the Csrf is checked by Magento. You need to do something like this.
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.