我正在尝试使用自定义模板为我的Wordpress设置自定义静态首页.
我创造landingpage.php的wp-content/themes/my_theme,我在我的模型的LandingPage WordPress管理中选择创建一个新的页面.
如果我去my_website.com/landing-page/我的自定义页面工作和'Hello World!' 出现了,但如果我将自定义页面设置为静态首页并转到my_website.com/我的"Hello World!" 消息不显示.
我的landingpage.php代码:
<?php /* Template Name: LandingPage */ ?>
<?php get_header(); ?>
<div class="wrap">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'template-parts/page/content', 'page' );
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile;
?>
<h1>Hello World!</h1>
</main>
</div>
</div>
<?php get_footer();
Run Code Online (Sandbox Code Playgroud)
任何的想法?谢谢
我一直在阅读这个问题和相关文章的几种变体,尽管我最终确实解决了我的问题(最终s/utf8mb4/utf8/g在我的sql脚本上完成了工作),但我仍然茫然为什么这可以在MySQL上正常工作,但是不得不在MariaDB中搜索替换。
设置:
在两台机器上,我都创建了数据库,如下所示:
CREATE DATABASE `test` COLLATE 'utf8mb4_general_ci'
Run Code Online (Sandbox Code Playgroud)
输入脚本是一个16MB的SQL文件,包含大约300个表,所有表都声明为 ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPRESSED
当我尝试在MariaDb上导入此文件时,我得到:
ERROR 1071 (42000) at line 602: Specified key was too long; max key length is 767 bytes
Run Code Online (Sandbox Code Playgroud)
但是我在MySQL上导入了相同的文件而没有更改,所有表的创建都很好。
为了能够在MariaDB计算机上执行相同的操作,我需要s/utf8mb4/utf8/g在运行脚本之前执行上述操作。
问题的要点是:有没有一种方法可以设置MariaDB,以便可以以与MySQL中相同的格式导入文件?
关于@Cbroe提出的重复操作,它以两种方式失败:
1-它解释了MyIsam和InnoDB之间的索引大小差异(并且我在两种情况下都使用InnoDB,尽管它在MySQL中工作,但在MariaDB中失败)。
2-如果可能的话,它没有说明如何使MariaDB充当MySQL。由于可以将此脚本与此引擎一起使用,并且可以在MySQL上使用此编码,因此在MariaDB中是否可以这样做?如果没有,为什么不呢?
此外,我们已经有了一个有效的答案,该答案不同于所谓的重复答案。
我在PHP 7.3上安装了Xdebug pecl install xdebug
当我将这些设置添加到/etc/php/7.3/apache2/php.ini并重新加载apache时,页面失败并且没有数据发送到服务器.
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
zend_extension="/usr/lib/php/20180731/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE
xdebug.scream=1
Run Code Online (Sandbox Code Playgroud)
不知道为什么它不起作用.
在我的 AWS 日志中,我有这样的条目:
[Wed Feb 06 10:12:22.306730 2019] [php7:error] [pid 28445] [client 172.31.10.7:55646] PHP 致命错误:未捕获的错误:在 /var/app/current/project 中找不到类“comet_cache” -website-wordpress/wp-content/mu-plugins/comet-cache-ec2-enabler.php:41
当某些特定的 HTTP 500 请求发生时,这些条目会被记录下来。
检查代码后,我发现了以下内容(在提到的文件的第 41 行):
try {
comet_cache::clear();
} catch(Exception $e) {
// if comet cache is not activated, we want to continue anyway
}
Run Code Online (Sandbox Code Playgroud)
这基本上是有道理的 - 似乎没有找到类,但如果是这种情况,应该继续执行。PHP为什么会停止?
在Symfony 4中,可以从控制器通过以下命令获取项目的根路径:
// From a Controller Class, in the src/Controller dir
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
// ...
Class myController extends Controller{
// ...
// in a public method
$rootDir = $this->get('kernel')->getRootDir();
Run Code Online (Sandbox Code Playgroud)
但是,如何从服务类获取根路径?我尝试过这种(丑陋的)方式
// From a Service Class, in the src/Service dir
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
// ...
Class myService extends Controller{
// ...
// in a public method
$rootDir = $this->get('kernel')->getRootDir();
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我得到了错误:
"Call to a member function get() on null"
Run Code Online (Sandbox Code Playgroud)
为什么此解决方案不起作用?
我需要知道以下方法之间有什么区别,以及每种方法的主要目标或特点是什么?
如果有人可以教我这方面的知识或给我一个很好的参考以供参考,那就太好了。
$class = app()->make(ClassA::class);
Run Code Online (Sandbox Code Playgroud)
对比
$class = new ClassA();
Run Code Online (Sandbox Code Playgroud) 我正在使用 Symfony 的登录表单,但如果输入的用户名是“FOO”并且数据库中存储的是“foo”,则我无法登录。我正在使用 Postgres。这意味着用户名字段区分大小写。我能做些什么?
我正在使用 Symfony 4 和 Api-Platform 开发一个应用程序。
我xxxException根据这些文档创建了一个自定义错误。我在手术后使用过它,效果很好。
现在我想在访问some-url/api.
怎样做,才会出现下图这样的情况呢?
我有这样的事情:
public function postRemove(LifecycleEventArgs $args)
{
$entity = $args->getObject();
$entity->getId();
}
Run Code Online (Sandbox Code Playgroud)
$entity 具有所选表中除 id 外的所有属性,id 始终为 null
我希望它具有我要删除的项目的 ID。
我正在 mysql 中创建组织表。
\n\n该实体被称为Organisation并且它有一个password字段。
当我尝试使用UserPasswordEncoderInterface它时,它需要user实体,所以这不起作用。我尝试使用PasswordEncoderInterface,但它说该服务不存在。这里可以做什么?
这是我的代码:
\n\n public function register(Request $request, EntityManagerInterface $entityManager, PasswordEncoderInterface $encoder)\n {\n $organisation = new Organisation();\n\n $form = $this->createForm(OrganisationRegisterType::class, $organisation);\n\n $form->handleRequest($request);\n\n if ($form->isSubmitted() && $form->isValid()) {\n $plainPassword = $form->getData()->getPassword();\n $encoded = $encoder->encodePassword($plainPassword, null);\n $organisation->setPassword($encoded);\n\n $entityManager = $this->getDoctrine()->getManager();\n $entityManager->persist($organisation);\n $entityManager->flush();\n\n $this->addFlash(\n \'success\',\n \'Organizacija sukurta s\xc4\x97kmingai. Nurodytu el. pa\xc5\xa1tu buvo i\xc5\xa1si\xc5\xb3sta prisijungimo informacija\'\n );\n }\nRun Code Online (Sandbox Code Playgroud)\n\n这是我得到的错误:
\n\n\n\n无法自动装配“App\\Controller\\OrganizationController::register()”的参数 $encoder:它引用接口“Symfony\\Component\\Security\\Core\\Encoder\\PasswordEncoderInterface”,但不存在此类服务。您是否创建了一个实现此接口的类?
\n
php ×7
symfony ×5
symfony4 ×3
doctrine ×1
doctrine-orm ×1
fatal-error ×1
laravel ×1
mariadb ×1
mysql ×1
oop ×1
postgresql ×1
wordpress ×1
xdebug ×1