我有一个相对的文件夹'files / crm-upload',我想在其中上传文件。我的代码检查is_writable()是否为true,只有在这种情况下才继续进行。
该文件夹作为带有rw和sec = sys的NFS共享挂载。
我已经编写了一个测试脚本,我也在apache上执行了该脚本以查看访问权限,结果是:
files/crm-upload/php_touch modification time has been changed to present time
My effective UID is 33 but my UID is really 33
files/crm-upload/ is owned by 33 and has permissions 40777
is_readable('files/crm-upload/') gives true
is_readable('files/crm-upload/php_touch') gives true
is_writable('files/crm-upload/') gives false
is_writable('files/crm-upload/php_touch') gives true
is_writable('files/crm-upload/25/') gives true
is_writable('files/images/') gives true
file_exists('files/crm-upload/') gives true
file_exists('files/crm-upload/php_touch') gives true
Some stat uids:
files/crm-upload/: 33
files/crm-upload/php_touch: 33
files/images/: 33
Run Code Online (Sandbox Code Playgroud)
所以:
怎么可能只有已挂载共享的根文件夹不可写,而其他所有东西都不能写?
这是Ubuntu 18.04。客户端,没有运行SELinux ...
我正在努力通过类别名称从注入的已标记服务组中获取特定服务。
这是一个示例:我标记实现DriverInterface为的所有服务app.driver并将其绑定到$drivers变量。
在其他一些服务中,我需要获取所有已标记app.driver并实例化的驱动程序,并且仅使用其中一些驱动程序。但是需要的驱动程序是动态的。
services.yml
_defaults:
autowire: true
autoconfigure: true
public: false
bind:
$drivers: [!tagged app.driver]
_instanceof:
DriverInterface:
tags: ['app.driver']
Run Code Online (Sandbox Code Playgroud)
其他一些服务:
/**
* @var iterable
*/
private $drivers;
/**
* @param iterable $drivers
*/
public function __construct(iterable $drivers)
{
$this->drivers = $drivers;
}
public function getDriverByClassName(string $className): DriverInterface
{
????????
}
Run Code Online (Sandbox Code Playgroud)
因此,将实现的服务DriverInterface注入到$this->driversparam中作为可迭代的结果。我只能foreach通过它们,但是所有服务都将被实例化。
是否有其他方法可以将这些服务注入,以通过类名从它们获得特定服务而无需实例化其他服务?
我知道有可能将那些驱动程序公开并改为使用容器,但是我想避免以其他方式将容器注入服务中。
我正在开发一个基于模块的 Laravel CMS。
这是私有的,这意味着我需要使用 git 部署令牌,因此我可以使用 Composer 来安装/管理这些模块。
例子:
"repositories" : {
"repo-name": {
"type": "vcs",
"url": "https://gitlab+deploy-token-xxxxx:password@gitlab.com/url-to-repo.git"
},
Run Code Online (Sandbox Code Playgroud)
这通常工作得很好,这意味着当我创建一个新项目时,我可以安装我的模块。
但是 Windows / Git 将部署令牌保存为 Windows 中的 Git 凭据,覆盖了我的正常登录。
这意味着,当我开发模块并想要推送更改时,Gitlab 会拒绝它,因为 Git 尝试使用部署密钥而不是我的正常 Git 凭据来上传我的更改。
我的问题:是否有可能以某种方式阻止 Git 将此部署令牌保存为全局 Git 凭证,这样它就不会覆盖我常用的 Git 凭证?
我正在开发一个应用程序,其中有一些处理程序作为我希望能够调用的服务。他们都实现了一个ItemHandlerInterface.
我希望能够在控制器中检索所有ItemHandlerInterface服务集合,而无需手动连接它们。
到目前为止,我具体标记了它们:
服务.yaml
_instanceof:
App\Model\ItemHandlerInterface:
tags: [!php/const App\DependencyInjection\ItemHandlersCompilerPass::ITEM_HANDLER_TAG]
lazy: true
Run Code Online (Sandbox Code Playgroud)
并尝试在控制器中检索我的服务集合。如果只有一个服务实现,它就可以工作ItemHandlerInterface,但是一旦我创建了多个服务(如下面的TestHandler和 )Test2Handler,我最终会得到一个The service "service_locator.03wqafw.App\Controller\ItemUpdateController" has a dependency on a non-existent service "App\Model\ItemHandlerInterface".
如何动态检索实现我的接口的所有服务?
一种肮脏的解决方案是强制所有ItemHandlerInterface内容public: true并传递Container给我的控制器构造函数。但这很丑陋,我想找到一种更优雅的方式。
项目更新控制器
namespace App\Controller;
use App\Model\ItemHandlerInterface;
use App\Service\ItemFinder;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Debug\Exception\ClassNotFoundException;
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use App\Model\Item;
use Psr\Container\ContainerInterface;
/**
* Class ItemUpdateController
*
* @package App\Controller
*/
class ItemUpdateController extends AbstractController
{
/**
* …Run Code Online (Sandbox Code Playgroud) 我有一个在 Symfony 5.0 上在 3 台不同的 Windows 10 PC 上进行开发的本地设置,当 PHP 版本为 7.3 时,它们都没有问题,当 PHP 版本为 7.4 时,它们都有相同的问题。
它发生在任何需要用户输入的执行中,例如: * php bin/console make:entity
* php bin/console doctrine:migrations:migrate。
其他php bin/console make:migration不需要用户输入的命令可以正常工作,因此等待输入似乎是问题所在。
以非交互模式运行它们适用于是/否,但对很多人来说是不可能的,比如 make:entity
这是终端的输出:
PS C:\path\project> php bin/console make:entity
Class name of the entity to create or update (e.g. VictoriousPuppy):
>
Aborted.
make:entity [-a|--api-resource] [--regenerate] [--overwrite] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<name>]
PS C:\path\project>
Run Code Online (Sandbox Code Playgroud)
中止立即发生,无需等待输入。我安装了 7.3 和 7.4 两个版本,切换到 7.3 使其工作正常,所以我查看了这两个 …
我正在尝试将图像放入带有ImageTk和的窗口中PhotoImage。下面是代码:
import tkinter as tk
import random as r
from PIL import ImageTk, Image
window = tk.Tk()
HEIGHT = window.winfo_screenwidth()
WIDTH = window.winfo_screenheight()
RESOL = str(str(HEIGHT) + "x" + str(WIDTH+7) + "+" + str(-7) + "+" + str(0))
window.geometry(RESOL)
x = int(HEIGHT)/2
y = int(WIDTH)/2
updatex = HEIGHT + (0.6 * HEIGHT)
main = tk.Frame(window, height = WIDTH, width = HEIGHT)
main.configure(bg = "white", highlightthickness = 0)
main.place(x = x, y = y, anchor = "center") …Run Code Online (Sandbox Code Playgroud) 在运行时作曲家update,install,require,dump-autoload,等; 我突然开始收到一条黄色的弃用通知,上面写着:
位于 ./foo/bar/utility/baz.php 的 Foo\Bar\Baz 类不符合 psr-4 自动加载标准。跳过。
在 Composer 2.0 之前,曾经得到:
弃用通知:位于 ./foo/bar/Baz.php 的 Foo\Bar\Baz 类不符合 psr-4 自动加载标准。它不会再在 Composer v2.0 中自动加载。在 phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
为什么我会收到此通知或警告?我需要什么才能摆脱它并为 Composer 2.0 做好准备?
我有这样的事情:
/**
* @ORM/Entity
* @ApiResource(
* itemOperations={
* "put_cancel": {
* "method": "PUT",
* "path": "/task/{id}/cancel",
* "messenger": "input",
* "input": CancelTaskCommand::class,
* "output": false
* },
* }
* )
*/
class Foo {}
Run Code Online (Sandbox Code Playgroud)
取消FooCommand.php
final class CancelFooCommand
{
/**
* @var string
* @ApiProperty(
* identifier=true,
* )
*/
public string $id = '';
/**
* @var string
* @ApiProperty(
* attributes={
* "openapi_context"={
* "type": "string"
* }
* }
* )
*/
public string $note …Run Code Online (Sandbox Code Playgroud) 我一直在使用 symfony/console 来创建命令并像这样注册它们,一切正常:
垃圾箱/控制台:
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use App\Commands\LocalitiesCommand;
use Symfony\Component\Console\Application;
$app = new Application();
$app->add(new LocalitiesCommand(new LocalitiesGenerator()));
$app->run();
Run Code Online (Sandbox Code Playgroud)
src/Commands/LocalitiesCommand.php:
<?php
declare(strict_types=1);
namespace App\Commands;
use App\LocalitiesGenerator;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
final class LocalitiesCommand extends Command
{
protected static $defaultName = 'app:generate-localities';
public function __construct(private LocalitiesGenerator $localitiesGenerator)
{
parent::__construct();
}
protected function configure(): void
{
$this
->setDescription('Generate localities.json file')
->setHelp('No arguments needed.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->localitiesGenerator->generateJsonLocalities();
$output->writeln("File localities.json generated!"); …Run Code Online (Sandbox Code Playgroud) 我创建了一个新的 Symfony 项目,并且不断收到此消息“DoctrineMigrationsBundle 需要启用 DoctrineBundle”。错误并且无法摆脱它。显然我是这个星球上唯一一个收到此错误的人,因为谷歌并没有太大帮助。
在 config/bundles.php 文件中,我有以下内容应该“启用”DoctrineBundle,但我缺少一些东西并且无法告诉它是什么。
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
];
Run Code Online (Sandbox Code Playgroud) php ×8
symfony ×6
composer-php ×2
apache ×1
autoload ×1
autowired ×1
doctrine ×1
doctrine-orm ×1
git ×1
linux ×1
nfs ×1
photoimage ×1
php-7.4 ×1
python ×1
python-3.x ×1
symfony-dependency-injection ×1
tkinter ×1
ubuntu ×1