I try to build a simple application using Zend Framework 2 and Doctrine 2. I decided to use YAML config files so my doctrine.yml file is as follow:
driver:
application_entities:
class: 'Doctrine\ORM\Mapping\Driver\AnnotationDriver'
cache: 'array'
paths:
- '__DIR__/../src/__NAMESPACE__/Entity'
orm_default:
drivers:
'Application\Entity': application_entities
authentication:
orm_default:
object_manager: 'Doctrine\ORM\EntityManager'
identity_class: 'Application\Entity\User'
identity_property: 'login'
credential_property: 'password'
configuration:
orm_default:
metadata_cache: 'array'
query_cache: 'array'
Now, the question is: is my cache config proper? And how can I verify it's actually working?
Of course I know I should use some better driver than simple array but for the moment it's enough for me.
Doctrine provides a set of command-line tools to simplify common administration tasks such this. Here is an example list of available commands:
In your case, you should use orm:ensure-production-settings command to make sure that Proxy Generation, Metadata and Query cache configurations are correct.
Assuming that you are using DoctrineORMModule to integrate doctrine with zend framework 2, open the console and simply type:
$ cd /path/to/your/projectroot
$ php public/index.php orm:ensure-production-settings
The output will warn you if the caching configuration is incorrect.
Here is the detailed official documentation for doctrine console.
Related
I want to connect my laravel 5.7 application(I used the 3.4 version of jenssegers/mongodb) with a mongodb in atlas, I tried in localhost(I isntalled the mongo extension) and everything is ok but with atlas i got an error message:
Failed to parse MongoDB URI:
'mongodb://root%3Acluster0.xxx.mongodb.net%3A27017%2Fhddatabase%3FretryWrites%3Dtrue%26w%3Dmajority'.
Invalid host string in URI.
My env file:
DB_CONNECTION=mongodb
DB_DSN="mongodb://root:password#cluster0.xxx.mongodb.net:27017/hddatabase?retryWrites=true&w=majority"
DB_DATABASE=hddatabase
My database config:
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('DB_DSN'),
'database' => env('DB_DATABASE'),
],
TL;DR: The url is wrong. "+srv" part is missing.
Please copy the url from the Atlas Connection Wizard:
You can open the connection from the Cluster View:
Details
Atlas provides a replica set cluster of 3 mongo db instances by default. Your local database is standalone.
There are 2 formats to connect to mongodb:
mongodb:// is the legacy one that requires all members of the replica set to be explicitly present in the url. E.g.: mongodb://<username>:<password>#cluster0-shard-00-00.xxx.mongodb.net:27017,cluster0-shard-00-01.xxx.mongodb.net:27017,cluster0-shard-00-02.xxx.mongodb.net:27017/<dbname>?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true&w=majority
mongodb+srv:// is the "srv" format which lets the driver to retrieve replica set configuration from mongodb itself, so the url is much simpler: mongodb+srv://<username>:<password>#cluster0.xxx.mongodb.net/<dbname>?retryWrites=true&w=majority
You are using the later format and the legacy schema so the driver complains.
As a side note it is advisable to use configuration options username and password as documented in https://github.com/jenssegers/laravel-mongodb#configuration rather than pass them in the url. URL format requires special characters like #, /, etc in the password to be escaped, which unnecessarily complicates credentials management.
Try with this DNS maybe :
mongodb://root:password#cluster0.xxx.mongodb.net:27017
Even with the 'srv' format I'm getting the same error, The problem is that I'm using the version 3.4.0 of jenssegers/mongodb, I upgraded to version 3.4.6 and used the 'srv' format and problem is solved now !
So I have a CakePHP 3 project and want to load FluentDOM, a PHP plugin not specifically written for CakePHP.
According to both software documentations, Composer is the way to go. In my understanding, all I would have to do is the following:
run composer require fluentdom/fluentdom in powershell
run composer require fluentdom/selectors-phpcss in powershell
OR
add the following to composer.json in the project's root directory:
"require": {
"fluentdom/fluentdom": "^7.0",
"fluentdom/selectors-phpcss": "^1.1"
}
run composer update in powershell
Both ways will install the desired plugins to vendor/fluentdom/{pluginname}/ as expected, but /vendor/cakephp-plugins.php won't include them, as implied by CakePHP's plugin installation manual.
The following attempt to load either plugin in a controller by writing
use Cake\Core\Plugin;
Plugin::load('fluentdom/fluentdom');
Plugin::load('fluentdom/selectors-phpcss');
would cause an exception that the desired plugins were not found in plugins/ :
Make sure your plugin fluentdom/fluentdom is in the {absolute project path}\plugins\ directory and was loaded
-- Which is already odd, because Composer wouldn't install anything there to begin with.
I found that I might get around this issue by manually extending vendor/cakephp-plugins.php to include the correct paths:
'fluentdom/fluentdom' => $baseDir . '/vendor/fluentdom/fluentdom/',
'fluentdom/selectors-phpcss' => $baseDir . '/vendor/fluentdom/selectors-phpcss/'
(However, that doesn't seem the way to go, because this file is auto-generated and overwritten by Composer after every update.)
And even then, the final issue still persists: although the plugins seem to be loaded successfully (confirmed by running Plugin::loaded()), I'd finally get the following exception when trying to access FluentDOM's classes as described in their wiki:
$document = new FluentDOM\DOM\Document();
Class 'App\Controller\FluentDOM\DOM\Document' not found
Does the plugin miss out on having its' autoload executed?
Even extending the line in my controller to Plugin::load('fluentdom/fluentdom', ['autoload' => true]);, but doesn't seem to help either; according to CakePHP's doc, that shouldn't be necessary anyway.
So what am I missing?
Found it! First of all, I had the false presumption that Plugins and Vendor Packages are more or less the same: they are not; thanks to Greg Schmidt for pointing this out in the question's comments.
The issue was in the line of how I tried to access FluentDOM's class. While
$document = new FluentDOM\DOM\Document();
worked in a standalone php file, it didn't within the Cake project; I was missing a backslash:
$document = new \FluentDOM\DOM\Document();
So, the entire path of actions to load a Vendor Package is merely:
run composer require fluentdom/fluentdom in powershell
run composer require fluentdom/selectors-phpcss in powershell
Use the new classes right away with $document = new \FluentDOM\DOM\Document();
No further steps required. Side note: Composer seems to refresh autoload config after installing a vendor file with composer require {vendor}/{package}, but in case it doesn't, or autoload config is messed up from earlier experiments, composer dumpautoload should fix it.
Apparently there are two ways to configure scrutinizer-ci to use custom phpCodeSniffer standards. The documentation only mentions phpcs use in "build" node and it isn't clear if they do different things or if one is preferred over the other.
Docs reference: https://scrutinizer-ci.com/docs/tools/php/code-sniffer/
What's the difference between running the checks inside "build" or "checks"? Should I use both?
checks:
php:
custom_coding_standard:
ruleset_path: 'ruleset.xml'
build:
tests:
override:
- 'phpcs-run --standard=ruleset.xml'
The official answer was to use phpcs-run.
build:
tests:
override:
- 'phpcs-run --standard=ruleset.xml'
The phpcs-run wrapper retrieves the latest version of phpcs on every build. Otherwise a preinstalled version of it is used. So usually the best way of running phpcs is using the wrapper in the build section.
Is it possible to set SonarQube's web context path using a command line parameter?
Usually you would set property sonar.web.context=/sonarqube (or similar) in sonar.properties file. But I'm using Docker and would like to avoid editing sonar.properties.
With Docker Compose I got the following which is working like a charm for other command line parameters:
services:
sonarqube:
image: sonarqube:5.4
[...]
entrypoint:
- ./bin/run.sh
- -Dsonar.log.level=INFO
- -Dsonar.web.context=/sonarqube
But it seems to ignore -Dsonar.web.context=/sonarqube :( Is there a way to pass SonarQube a different context path?
Additional info: This is corresponding run.sh file.
With SonarQube 5.4 this is bound to fail: sonar.web.context was dropped in SonarQube 5.4 (SONAR-7122, suggested alternative being to use a sub-domain) and re-introduced in 5.5 (SONAR-7494) following community feedback.
They added the context back in 5.5 RC1
https://jira.sonarsource.com/browse/SONAR-7494
Current System: Windows XP / Windows 7 (problem occuring for both)
After following the guidelines for deployment from the following:
https://devcenter.heroku.com/articles/python
and by testing by using a simple poll application I am successfully able to push the application through heorku except that after checking the logs the following error appears:
2012-04-27T08:14:42+00:00 app[web.1]: django.core.exceptions.ImproperlyConfigure
d: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No m
odule named _sqlite3
This also occurs when attempting to sync the database.
Here is the current configuration of the database in the settings.py file:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'database.sqlite', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
I am aware is it a sqlite3 database, and I have been told that it should still allow heroku to deploy the app without any errors.
I have followed through using the following potential solutions that are related to this problem:
No module named _sqlite3
How do I set up SQLite with a Django project?
http://groups.google.com/group/django-users/browse_thread/thread/185f981f432346f1
Any help will be appreciated! Please let me know if additional Information is needed.
Heroku does not support sqlite, since it only provides a read-only filesystem.
I had the same error with the settings file. Looking through the Heroku logs, it turned out that my settings.py file was failing for various reasons. Once I fixed those issues, Django stopped complaining about missing database settings.
One of the things that caused this issue was a monkey patch I was using to allow sub-selects as tables in QuerySet extra(). This patch is at the end of my settings file.
# Override default behaviour of compiler to quote table names when table name is a sub-query
from django.db.models.sql.compiler import SQLCompiler
_quote_name_unless_alias = SQLCompiler.quote_name_unless_alias
SQLCompiler.quote_name_unless_alias = lambda self,name: name if name.startswith('(') else _quote_name_unless_alias(self,name)
This patch apparently requires that DATABASES already be correctly specified at that point. Since Heroku appends the magic DATABASES configuration to the end of the settings file (i.e. after the monkey patch), I had to manually insert their configuration above my monkey patch.