Symfony: Widget schema does not include the following field(s): title - php

I'm working in a symfony-based project. I did not do.
The page works in a simple webserver (debian+apache+php) and i move this from my home server, with Debian + Nginx + php-fpm, this works, but it throws an error that did not.
The complete error is here: http://pastebin.com/PCy0v1J6

Have you moved all your files? I guess that Brick is an object in your schema.yml, and it has a property 'title'. You should have a file BaseBrickForm.class.php in lib/form/doctrine/base, if you don't you should execute ./symfony doctrine:build --all-classes. It's common to have the autogenrated classes ignored by a versioning system, so it may be the source of your problem.

In SF_ROOT_DIR/lib/form/brickForm.class.php line 23ff you have :
$this->useFields(array('title', 'content'));
Please check the widgets defined in your BaseBrickForm.class.php file and if brickForm.class.php is extending BaseBrickForm !

Related

Cannot find name for "en_UK" locale code - error in Sylius

So I'm setting up a sylius project using docker and am getting an error when I first tried to load the page. The docker set up on sylius website didn't seem to work so I made my own docker files and can successfully start the docker containers. The error is below:
An exception has been thrown during the rendering of a template ("Cannot find name for "en_UK" locale code").
During the installation, sylius asks whether you want en_US or something different so I typed en_UK, presuming that was the notation required. Upon setup completion, I tried to load root page and I get the error message above. However, strangely, on the symfony toolbar on the error page it says US web store.
If anyone could help at all it would be greatly appreciated. Thank you in advance.
Possible ways:
go to localhost/admin, enter your login/password which you entered at the install moment, open Channels section, and there add change default locale/add new to locale list;
modify a <project-root>/config/services.yaml and change locale value to another;
in the worst case try to run php bin/console sylius:install command and reinstall database with a en_US at the beginning, then edit Admin section to en_UK
en_UK means "English (Ukraine)". No wonder it was missing. What you wanted was probably en_GB.

Symfony messenger can't consume messages

Few weeks ago I set up a Message system with Symfony Messenger and it worked great.
Today I wanted to create new object through message, so I went to my server and type the command to consume message
First I had this result
$ bin/console messenger:consume-messages amqp_notifications
/usr/bin/env: ‘php\r’: No such file or directory
It never happened before with my files, and I never changed the line ending or encoding of my file sin PHPstorm.
I tried to use $ php bin/console messenger:consume-messages amqp_notifications
but then I had this error.
Attempted to load class "AMQPConnection" from the global namespace.
Did you forget a "use" statement?
Pretty weird, because I have have the php-amqp ext installed as you can see on the screenshot of my phpinfo
I didn't change anything in my Message class or Handler.
Also, I tried to call new AMQPConnection() on a random action, just to try, and I didn't get the error.
I'm completely lost with this error this time, as everything is installed.
I use PHP 7.3.1 and symfony Messenger 4.2.2
It seems your second issue was already solved by ccKep on his comment.
The first one is that the specific shebang line #!/usr/bin/env php executes the first php found in the $PATH. So if you already have uninstalled it, which seems the case, or it has a symbolic link to another php version, you can get a wrong result.
Tries to check what is inside the $PATH and replace the PHP path for the correct one. You might get the place running which php.

CakePHP 3.0 not running on other machines

I've developed a small project on a machine, using CakePHP 3.0, and I need it to run on another machine. I've tried to install it on several other machines.
If I run the composer to install the CakePHP 3.0, then I copy my stuff to overwrite it, the project works. I've tried this on two machines and had no problem so far. If I don't run the composer, and just copy the stuff to the target machine, it gives me the following error. I've tried this on 3 machines, and every machine gives me this:
Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229
Fatal error: Class 'Locale' not found in /home/u113681897/public_html/vendor/cakephp/cakephp/src/I18n/I18n.php on line 229
I've copied the whole project to this server to test.
I told you this because I thought it has something to do with my problem. The point is that I have to run this on a machine that is not mine, and I can't install composer on it. The /public_html/vendor/cakephp/cakephp/src/I18n/ has files related to internationalization and localization, but my project will never be translated, so a workaround to make the project ignore those files would be enough to solve my problem.
The following code is an excerpt from the (...)/I18n/I18n.php that might be relevant:
<?php
namespace Cake\I18n;
use Aura\Intl\FormatterLocator;
use Aura\Intl\PackageLocator;
use Aura\Intl\TranslatorFactory;
use Cake\I18n\Formatter\IcuFormatter;
use Cake\I18n\Formatter\SprintfFormatter;
use Locale;
class I18n {
// lots of code here
public static function defaultLocale() {
if (static::$_defaultLocale === null) {
static::$_defaultLocale = Locale::getDefault() ?: 'en_US';
// the line above is the Line 229
}
return static::$_defaultLocale;
}
// many code here too
}
I've checked that another file also tries to access this Locale class, but I don't know if there are other files trying to access it as well. Many files from everywhere inside the project tries to access methods from I18n.php. I need it running but I can't figure out how to make it run.
Any help will be greatly appreciated.
As I just found out, prior to CakePHP 3.0, the installation must be done by composer, as stated in the 3.0 migration guide:
CakePHP should be installed with Composer
Since CakePHP can no longer easily be installed via PEAR, or in a shared
directory, those options are no longer supported. Instead you should use
Composer to install CakePHP into your application.
So it won't run on regular free web hosting services.

setting up phpChart in laravel

Environment:Amazon EC2. Ubuntu x64. (GD library installed)
I'm recently using phpChart for graph and report in laravel framework.
I'm stuck at the beginning stage.
Here's what I've done.
1.Unzip the contents in phpChart_Lite to /var/www/app/libraries/phpChart.
2.Edit composer.json and add :
"autoload": {
"classmap": [
...
"app/libraries"
]
},
3.run:composer dump-autoload
4.modify conf.php in phpChart_Lite
define('SCRIPTPATH',app_path().'/libraries/phpChart_Lite/');
Here's my test page code:
<?php
require_once(app_path()."/libraries/phpChart_Lite/conf.php");
$pc = new C_PhpChartX(array(array(11, 9, 5, 12, 14)),'basic_chart');
$pc->draw();
?>
ps.my app_path() is verified by "echo app_path()" and it is "/var/www/app".
Here's my error message:
Unknown: Failed opening required '/var/www/public//var/www/app/libraries/phpChart_Lite//conf.php'
(include_path='/var/www/vendor/phpseclib/phpseclib/phpseclib:.:/usr/share/php:/usr/share/pear')
After a lot of try-and-error, I somehow found the root cause, I guess.
There are actually two main issue there. And here's my solution.
1.For my issue explained in the very first post.
In the conf.php file in phpChart_Lite folder. The SCRIPTPATH is somehow prefixed with /var/www/public.
However, in my apache2.conf file states the directory to be /var/www. Regardless this prefix, I use a absolute path for SCRIPTPATH. The following modification works for me:
define('SCRIPTPATH','../app/libraries/phpChart_Lite/');
The error was gone. But the second issue appears, that is the chart doesn't show up.
Open the Chrome Developer Tool(press F12). On the 'Console' tab, I found error 404 for loading phpChar_Lite/js. One of the error messages as following:
http://myip/app/libraries/phpChart_Lite/js/highlighter/styles/zenburn.css
As the design of Laravel, only public folder can be access by external request.
So I got second issue. And here's my solution.(not a secured method)
2.Move the phpChart_Lite to public folder. Modify the code of test page:
include_once(public_path()."/phpChart_Lite/conf.php");
Modify the conf.php in public/phpChart_Lite:
define('SCRIPTPATH','phpChart_Lite/');
Everything's just fine now.
If you consider phpChart is too complicate to configure with, you might want to try pChart2.0.
It doesn't require much setting. But the graph is terribly ugly.
I prefer phpChart for it's graph and function calls, though the setting is a little complicated and not laravel friendly.

"No tests executed" I cannot run any PHP test in NetBeans at all

I am very new to NetBeans and I just wanted to run a Code Coverage teston my code developed earlier. I do not know what I am doing wrong.
I am using NetBeans 7.3.1 with Wamp Server 2.4, installed PHPUnit and Skeleton Generator through PEAR, and set those files in NetBeans settings.
I made the project using an existing sources. Running in my browser seems OK. I can even debug with XDebug.
But when I right click on the project name and "Test", it says "No tests executed.(0.0 s)" in the Test Result window, and this in the Output window:
PHPUnit 3.7.23 by Sebastian Bergmann.
Configuration read from C:\wamp\www\test\configuration.xml
Time: 141 ms, Memory: 2.00Mb
No tests executed!
Generating code coverage report in Clover XML format ... done
I tried running test on a PHP file, it returns an information dialog box "Test file for the selected source file was not found."
I right clicked on the PHP file, and selected "Tools->Create PHPUnit tests", it returns a warning dialog box "Tests were not generated for the following files: (file name) Review the log in Output Window." but nothing was changed in the Output window.
I generated PHPUnit Bootstrap and XML Configuration, but they did not help.
I wished I can provide screenshots, but I cannot. I am trying to be specific as possible.
I appreciate any help.
I got this error too.. I also got this in the Output tab
Fatal error: Class 'package\path\Tests\TestCase' not found in project\path\package\path\Tests\ClientTest.php on line 25
Here, TestCase is the subclass of PHPUnit_Framework_TestCase and that, along with the current test file is in a different directory structure than the source files. So, in my case, it was a path issue.
Something I noted is I need to add a bootstrap file to include files in the test path and the source path to the runtime.
This bootstrap could be generated by NetBeans. See instructions here: https://netbeans.org/kb/docs/php/phpunit.html#project-specific-configurations
I of course, had another bootstrap.php (added by another developer). I only had to link the bootstrap like follows,
Good luck!
PHPUnits message:
No tests executed!
just means that no tests were found. This can have multiple reasons:
First of all, if there are no tests, no tests are executed.
But it is also possible that there are tests, but the configuration says to skip those (for example some tests are grouped into a group named slow and the configuration XML says to exclude slow from being run).
For your case this most certainly is a configuration issue. I'm not fluent with Netbeans but as you can successfully execute PHPUnit already, that part of your setup looks working.
Next step is to find out when you invoke the test-runner where it looks for tests. It might just be that the tests directory is missing or not specified. E.g. check which configuration is in configuration.xml for example and compare that with the documentation to double-check all settings.
This is not a very concrete answer and somebody who is more fluent with Netbeans might help more, however as you'er not showing further screenshots, this is my honest best bet how to go on with trouble-shooting and why.
Seems I am getting closer to the solution. I found out the problem is not in the configurations, but in the code itself.
I do not know if this is a silly problem, but seems the test only accepts PHP codes written in OOP. I tried making another file with a class and I can make test file out of it with no problem. At least I can see the test result changes from "No test executed" to "No test passed, 1 test skipped"
My codes are written for months without OOP and I know nothing about it at all. Does this mean I have to rewrite all of them again?
It will happen when you put an assertion in a constructor of your test class and this assertion fails.
Then you will see only the warning 'No tests executed!' (not very helpful) but i suppose one should not put assertions in the constructors (this is in phpunit 4.1~).
for it was because my test names were not starting with 'test'

Categories