This package is deprecated. Please use yiisoft/app or yiisoft/yii-demo instead.
yiisoft / yii-base-web Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://www.yiiframework.com/
License: BSD 3-Clause "New" or "Revised" License
Home Page: https://www.yiiframework.com/
License: BSD 3-Clause "New" or "Revised" License
This package is deprecated. Please use yiisoft/app or yiisoft/yii-demo instead.
I'm using new app template, but to run tests i have created yiitest
and yiitest.bat
into bin
directory.
#!/usr/bin/env php
<?php
/**
* Yii console bootstrap file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
require(dirname(__DIR__). '/vendor/autoload.php');
require(dirname(__DIR__) . '/vendor/yiisoft/yii2/Yii.php');
$config = yii\helpers\ArrayHelper::merge(
require(dirname(__DIR__) . '/config/console.php'), [
'components' => [
'db' => require(__DIR__ . '/../config/db.test.php')
]
]
);
$application = new yii\console\Application($config);
$exitCode = $application->run();
exit($exitCode);
But i didn't like this solution then i have the follow suggestion to solve it:
config/test.php
return yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/console.php'), [
'id' => 'app-test',
'aliases' => [
'@tests' => dirname(__DIR__) . '/tests'
],
'components' => [
'cache' => [
'class' => 'yii\caching\FileCache',
],
'session' => [
'class' => 'yii\web\CacheSession'
],
'db' => require(__DIR__ . '/db.test.php')
]
]
);
yii\console\controllers\TestController
bin/yii
with params (bin/yii test --config=test
)May reference ones in basic/advanced apps.
Create a new app following installation and run on docker
Running app on docker
This site can’t be reached docker.host took too long to respond.
Search Google for docker host 30080
ERR_CONNECTION_TIMED_OUT
Q | A |
---|---|
Yii version | ^3.0@dev |
PHP version | x |
Operating system | x |
I like this template but it seems it still is under development.
It seems this template is mature enough though.
Should I use it to build new apps? Thanks.
php bin/yii serve
Server started
Document root "src/web" does not exist.
Q | A |
---|---|
Yii version | 2.1-dev |
PHP version | 7.2.* |
Operating system | *nix |
Should be considered but since there are problems running containers natively under Windows and MacOS it may make sense to still run it in Vagrant container...
See basic app and yiisoft/yii2-app-advanced#250
Create an app/project from this repo
To get an app (since it's in the name)
A (non-working) module ;) See also #40 (comment)
Q | A |
---|---|
Yii version | 3.0 |
PHP version | any |
Operating system | any |
Install this application base
I'd expect to get yii-console
only for yii-base-cli
.
It's installed because of https://github.com/yiisoft/yii-base-web/blob/master/composer.json#L30
Try to install this package in yii-project-template
Ideally no manual config editing needed, default config should be merged by composer-config-plugin
I have to add several config options:
ServerRequestFactoryInterface::class => Psr17Factory::class,
UriFactoryInterface::class => Psr17Factory::class,
UploadedFileFactoryInterface::class => Psr17Factory::class,
StreamFactoryInterface::class => Psr17Factory::class,
ResponseFactoryInterface::class => Psr17Factory::class,
UrlMatcherInterface::class => Reference::to(RouterInterface::class),
UrlGeneratorInterface::class => Reference::to(RouterInterface::class),
EmitterInterface::class => SapiEmitter::class,
in addition to the above I need to add
AppRouterFactory.php
Controller.php
MiddlewareDispatcherFactory.php
which look project dependent, I am not sure how to proceed with these.
Q | A |
---|---|
Version | master |
PHP version | 7.4 |
Operating system | Debian |
This is a more general question which config options are needed for the web-base, since I am not very experienced with Yii 3.x at the moment.
Moreover I think we can remove several other defaults from this packages, such as db
or console
.
I'd like to get some advice if this is the right path.
Related: #17
composer create-project --prefer-dist --stability=dev yiisoft/app myapp
an index.php file public
no index.php in public
Q | A |
---|---|
Yii version | 3 |
PHP version | 7.2 |
Operating system | macos |
Dependabot can't resolve your PHP dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- yiisoft/view 3.0.x-dev requires psr/event-dispatcher-implementation 1.0.0 -> no matching package found.
- yiisoft/mailer dev-master requires yiisoft/view ^3.0@dev -> satisfiable by yiisoft/view[3.0.x-dev].
- Installation request for yiisoft/mailer dev-master -> satisfiable by yiisoft/mailer[dev-master].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
Dependabot can't resolve your PHP dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- yiisoft/view 3.0.x-dev requires psr/event-dispatcher-implementation 1.0.0 -> no matching package found.
- yiisoft/yii-debug dev-master requires yiisoft/view ^3.0@dev -> satisfiable by yiisoft/view[3.0.x-dev].
- Installation request for yiisoft/yii-debug dev-master -> satisfiable by yiisoft/yii-debug[dev-master].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
We found it pretty handy to have the ability to get the (merged) app-config and environment from a command.
/**
* Shows application configuration
* Note that this action shows console configuration.
*
* @param null $key configuration section
*/
public function actionConfig($key = null)
{
// get config from global variable (TODO)
$data = $GLOBALS['config'];
if ($key) {
$keys = explode('.', $key);
if (isset($keys[0])) {
$data = $GLOBALS['config'][$keys[0]];
}
if (isset($keys[1])) {
$data = $GLOBALS['config'][$keys[0]][$keys[1]];
}
}
$this->stdout(VarDumper::dumpAsString($data));
}
/**
* Shows application environment variables.
*/
public function actionEnv()
{
$env = $_ENV;
ksort($env);
$this->stdout(VarDumper::dumpAsString($env));
}
Unfortunately it's a bit hacky in the config part, but this might be an issue for the core.
Split bit сonfig file (web|console.php) to small config (cache.php, logger.php ect...)
Small file edit more convenient.
Each file is responsible for one component. You can quickly find the required configs.
Example https://github.com/exileed/yii2-app/tree/feature/small-config/config
Using the app, as is, will not easily give you a backend/ frontend setup.
Previously there were advanced templates that solved the backend/ frontend issue.
It would be great if this one template could make such a setup possible without the need for advanced templates.
Was there something like this planned?
Q | A |
---|---|
Yii version | 2.1.x-dev |
PHP version | 7.2.1 |
Operating system | OSX |
It's necessary to split params.php
by environment section.
Maybe something like:
return [
'dev' => [
'adminEmail' => '[email protected]',
'db.dsn' => "mysql:host=devhost;dbname=development",
'db.charset' => 'utf8',
'db.username' => 'root',
'db.password' => ''
],
'prod' => [
'adminEmail' => '[email protected]',
'db.dsn' => "mysql:host=prodhost;dbname=production",
'db.charset' => 'utf8',
'db.username' => 'root',
'db.password' => ''
]
];
The template should introduce a proper versioning workflow, which allows the developer to easily get/set/create/update the current version of the project.
Our current approach:
version:
$(shell echo $(shell git describe --long --tags --dirty --always) > ../src/version)
@echo $(shell cat ../src/version)
For reference: PHP helper for versions
This could also be "the feature" of an initial CLI command, yii app/version
.
I'm somewhat confused, as I understood the models would be in forms such as LoginForm and ContacForm, because not to put the model User in the forms directory, or simply move all models to models, it would be important to have it clearly defined.
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app myapp
http://localhost/myapp/public/
Starts yii project
ReflectionException: Class yii\web\YiiAsset does not exist in /var/www/html/myapp/vendor/yiisoft/yii2/di/Container.php:436
Stack trace:
#0 /var/www/html/myapp/vendor/yiisoft/yii2/di/Container.php(436): ReflectionClass->__construct('yii\\web\\YiiAsse...')
#1 /var/www/html/myapp/vendor/yiisoft/yii2/di/Container.php(365): yii\di\Container->getDependencies('yii\\web\\YiiAsse...')
#2 /var/www/html/myapp/vendor/yiisoft/yii2/di/Container.php(157): yii\di\Container->build('yii\\web\\YiiAsse...', Array, Array)
#3 /var/www/html/myapp/vendor/yiisoft/yii2/BaseYii.php(311): yii\di\Container->get('yii\\web\\YiiAsse...', Array, Array)
#4 /var/www/html/myapp/vendor/yiisoft/yii2/web/AssetManager.php(266): yii\BaseYii::createObject(Array)
#5 /var/www/html/myapp/vendor/yiisoft/yii2/web/AssetManager.php(239): yii\web\AssetManager->loadBundle('yii\\web\\YiiAsse...', Array, true)
#6 /var/www/html/myapp/vendor/yiisoft/yii2/web/View.php(286): yii\web\AssetManager->getBundle('yii\\web\\YiiAsse...')
#7 /var/www/html/myapp/vendor/yiisoft/yii2/web/View.php(291): yii\web\View->registerAssetBundle('yii\\web\\YiiAsse...', NULL)
#8 /var/www/html/myapp/vendor/yiisoft/yii2/web/AssetBundle.php(125): yii\web\View->registerAssetBundle('app\\assets\\AppA...')
#9 /var/www/html/myapp/src/views/layouts/main.php(13): yii\web\AssetBundle::register(Object(yii\web\View))
#10 /var/www/html/myapp/vendor/yiisoft/yii2/base/View.php(327): require('/var/www/html/m...')
#11 /var/www/html/myapp/vendor/yiisoft/yii2/base/View.php(245): yii\base\View->renderPhpFile('/var/www/html/m...', Array)
#12 /var/www/html/myapp/vendor/yiisoft/yii2/base/Controller.php(399): yii\base\View->renderFile('/var/www/html/m...', Array, Object(app\controllers\SiteController))
#13 /var/www/html/myapp/vendor/yiisoft/yii2/base/Controller.php(385): yii\base\Controller->renderContent('<div class="sit...')
#14 /var/www/html/myapp/src/controllers/SiteController.php(64): yii\base\Controller->render('index')
#15 /var/www/html/myapp/vendor/yiisoft/yii2/base/InlineAction.php(57): app\controllers\SiteController->actionIndex()
#16 /var/www/html/myapp/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#17 /var/www/html/myapp/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('', Array)
#18 /var/www/html/myapp/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('', Array)
#19 /var/www/html/myapp/vendor/yiisoft/yii2/base/Application.php(394): yii\web\Application->handleRequest(Object(yii\web\Request))
#20 /var/www/html/myapp/public/index.php(6): yii\base\Application->run()
#21 {main}
Q | A |
---|---|
Yii version | 2.1.x-dev |
PHP version | 7.2 |
Operating system | Ubuntu 16.04 |
https://github.com/yiisoft/yii2-app/blob/1c17dc5e29a6167eecf4a1a97f5d44aef4f386fb/config/web.php#L10
public function getRuntimePath()
{
if ($this->_runtimePath === null) {
$this->setRuntimePath($this->getBasePath() . DIRECTORY_SEPARATOR . 'runtime');
}
return $this->_runtimePath;
}
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app myapp
Create a new project with Yii 2.1
[InvalidArgumentException]
Could not find package yiisoft/yii2-app with stability dev.
Q | A |
---|---|
Yii version | 2.1 |
PHP version | 7.2 |
Operating system | Ubuntu 16.04 |
is need create /src/models/User.php ?
or
remove views/* \Yii::$app->user ?
Every directory in project's root is in singular form, but the tests folder in plural. I think it would be nice to resolve this issue before the release. I can prepare a pull request if you think it's a problem too.
View the respective page
Not Found
The requested URL /yii2-app/public/site/(about|contact|login) was not found on this server.
enablePrettyUrl is enabled by default. Without .htaccess
or any vhost config, the problem occurred.
Q | A |
---|---|
Yii version | 2.1.x-dev |
PHP version | 7.2 |
Operating system | Ubuntu 16.04 |
Installed this template following the README instructions:
composer create-project --prefer-dist --stability=dev yiisoft/app myapp
cd myapp
./vendor/bin/yii serve
The app to be served
For last step:
./vendor/bin/yii: No such file or directory
My vendor/bin/
directory only contains phpunit
The only yii
binary found within the tree is:
~/myapp/vendor $ find . -name yii
./yiisoft/yii-core/contrib/completion/bash/yii
Q | A |
---|---|
Yii version | 3 ? |
PHP version | 7.1.19 |
Operating system | macOS Darwin Kernel Version 18.2.0 |
Q | A |
---|---|
Yii version | 3.0 |
PHP version | 7.1.17 |
Operating system | Centos 7 |
Next yii\db\Exception: SQLSTATE[HY000]: General error: 1096 No tables used
The SQL being executed was: SELECT * in /home/example.com/public_html/vendor/yiisoft/db/src/Schema.php:664
Stack trace:
#0 /home/example.com/public_html/vendor/yiisoft/db/src/Command.php(1263): yii\db\Schema->convertException(Object(PDOException), 'SELECT *')
#1 /home/example.com/public_html/vendor/yiisoft/db/src/Command.php(1148): yii\db\Command->internalExecute('SELECT *')
#2 /home/example.com/public_html/vendor/yiisoft/db/src/Command.php(413): yii\db\Command->queryInternal('fetch', NULL)
#3 /home/example.com/public_html/vendor/yiisoft/db/src/Query.php(274): yii\db\Command->queryOne()
#4 /home/example.com/public_html/vendor/yiisoft/active-record/src/ActiveQuery.php(294): yii\db\Query->one(NULL)
#5 /home/example.com/public_html/vendor/yiisoft/active-record/src/BaseActiveRecord.php(111): yii\activerecord\ActiveQuery->one()
#6 /home/example.com/public_html/vendor/yiisoft/yii-base-web/src/models/User.php(83): yii\activerecord\BaseActiveRecord::findOne(Array)
#7 /home/example.com/public_html/vendor/yiisoft/yii-base-web/src/forms/LoginForm.php(77): yii\app\models\User::findByUsername('admin')
#8 /home/example.com/public_html/vendor/yiisoft/yii-base-web/src/forms/LoginForm.php(49): yii\app\forms\LoginForm->getUser()
#9 [internal function]: yii\app\forms\LoginForm->validatePassword('password', NULL, Object(yii\validators\InlineValidator))
#10 /home/example.com/public_html/vendor/yiisoft/core/src/validators/InlineValidator.php(72): call_user_func(Array, 'password', NULL, Object(yii\validators\InlineValidator))
#11 /home/example.com/public_html/vendor/yiisoft/core/src/validators/Validator.php(274): yii\validators\InlineValidator->validateAttribute(Object(yii\app\forms\LoginForm), 'password')
#12 /home/example.com/public_html/vendor/yiisoft/core/src/base/Model.php(364): yii\validators\Validator->validateAttributes(Object(yii\app\forms\LoginForm), Array)
#13 /home/example.com/public_html/vendor/yiisoft/yii-base-web/src/forms/LoginForm.php(63): yii\base\Model->validate()
#14 /home/example.com/public_html/vendor/yiisoft/yii-base-web/src/controllers/SiteController.php(78): yii\app\forms\LoginForm->login()
#15 /home/example.com/public_html/vendor/yiisoft/core/src/base/InlineAction.php(57): yii\app\controllers\SiteController->actionLogin()
#16 /home/example.com/public_html/vendor/yiisoft/core/src/base/Controller.php(160): yii\base\InlineAction->runWithParams(Array)
#17 /home/example.com/public_html/vendor/yiisoft/core/src/base/Module.php(542): yii\base\Controller->runAction('login', Array)
#18 /home/example.com/public_html/vendor/yiisoft/yii-web/src/Application.php(94): yii\base\Module->runAction('site/login', Array)
#19 /home/example.com/public_html/vendor/yiisoft/core/src/base/Application.php(525): yii\web\Application->handleRequest(Object(yii\web\Request))
#20 /home/example.com/public_html/public/index.php(14): yii\base\Application->run()
#21 /home/example.com/public_html/public/index.php(15): {closure}()
#22 {main}
Additional Information:
Array
(
[0] => HY000
[1] => 1096
[2] => No tables used
)
2018-09-09 01:08:28 [190.142.101.156][-][e05d5532cdeea664670fa57b4ff9aec5][info][application] $_GET = []
$_POST = [
'_csrf' => 'MuZl0hEYOz8SIZw_V_qcjAPKtCe29HHIo0h-i56owFYHhTqVXl5NVyVV31Y7nfrHcY_7YumBJKTqPgrZ9M32Ow=='
'LoginForm' => [
'username' => 'admin'
'password' => 'admin'
'rememberMe' => '1'
]
'login-button' => ''
]
Aliases are broken.
Example :
@vendor
-> src/vendor
Q | A |
---|---|
Yii version | 2.1.x-dev |
PHP version | 7.2 |
Operating system | *nix |
Dependabot can't resolve your PHP dependency files.
As a result, Dependabot couldn't update your dependencies.
The error Dependabot encountered was:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- yiisoft/view 3.0.x-dev requires psr/event-dispatcher-implementation 1.0.0 -> no matching package found.
- yiisoft/yii-gii dev-master requires yiisoft/view ^3.0@dev -> satisfiable by yiisoft/view[3.0.x-dev].
- Installation request for yiisoft/yii-gii dev-master -> satisfiable by yiisoft/yii-gii[dev-master].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.
Try to install app with command composer create-project --prefer-dist --stability=dev yiisoft/app myapp
.
App installs, but failed dependency of yii core.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- yiisoft/core 3.0.x-dev requires psr/container-implementation ^1.0 -> no matching package found.
- yiisoft/yii2-jquery 1.0.x-dev requires yiisoft/core ^3.0@dev -> satisfiable by yiisoft/core[3.0.x-dev].
- Installation request for yiisoft/yii2-jquery 1.0.x-dev -> satisfiable by yiisoft/yii2-jquery[1.0.x-dev].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
Newly created Yii3 project. All I want is just setup db-connection, but I can't understand where is the config file and what is its syntax. How to configure the unit tests to work with databases?
composer create-project --prefer-dist --stability=dev yiisoft/yii-project-template myapp
cd myapp
ls config/
common.php params.php
It seems like the application doesn't read params.php
file at all (I even made syntax error and didn't get any notices about it).
Use this template and find out in a few months that the login has a serious security issue. I think we had that in yii2-app-basic
and/or ...advanced
.
Or forget to remove the current user/login code when installing a custom module.
Easy updating/patching in case of bugs or security issues, i.e. with composer
.
Docs about how to install a user-management module, ie. yii2-usuario
.
It's pretty hard to patch anything which comes from the template.
CC: @cebe
I recently experimented with an web/API application template for Yii 2.1, see https://github.com/schmunk42/foxy-roxy-rabbit
One thing I'd really like to see is a src
folder for the application source code only, eg. no runtime
in it. It currently contains: 1 config, 1 controller, 1 layout, 1 view.
The public folder web
just contains index.php
A controversial point might be pkg
, a pro here is, that the root folder is much less cluttered. And that we can place files of any future package manager there, whether it's composer, npm/yarn or whatever.
I'd not recommend to use application tiers like in the current advanced app, if you want that - simply use this template multiple times and if you need to share code (formerly common
) use (private) vendor
packages.
This is just a proposal, feedback welcome.
Bonus: And there's also https://github.com/schmunk42/eucliid - which is a super-minimal template for CLI only applications, which can be converted to Yii 2.1.
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.