can't use Acos doctrine extension in my symfony 4 project with postgres database - doctrine

I'm trying to use numeric functions in my symfony 4 project.
I'm connected to postgres database :
DATABASE_URL=pgsql://postgres:postgres#postgres/mydatabase?serverVersion=11
In my doctrine.yaml file i added :
doctrine:
orm:
...
dql:
numeric_functions:
acos: DoctrineExtensions\Query\Mysql\Acos
cos: DoctrineExtensions\Query\Mysql\Cos
sin: DoctrineExtensions\Query\Mysql\Sin
I tried to make a Get resquest with postman
I received this error message :
"Attempted to load class \"Acos\" from namespace \"DoctrineExtensions\Query\Mysql\".\nDid you forget a \"use\" statement for another namespace?",

I think here you had a problem because you connected to Postgres DB, but tried to use Extension for MySQL( you can see it at the extension path 'DoctrineExtensions\Query*Mysql*\Acos' )

Related

Laravel 5.7 mongodb atlas connection problem using jenssegers/mongodb

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 !

Unable to connect to mongo (3.4) using robomongo (0.9.0) and username and password?

I have a mongo 3.4 instance with a cfg file thus:
systemLog:
destination: file
path: D:\Mongo\log\mongod.log
storage:
dbPath: D:\Mongo\db
Using robomongo version 0.9.0 I've added a user:
Now when I try and connect to the DB I get an error:
I've checked passwords etc all seems correct:
Without using auth all works as expected.
I've ran though a similar issue Mongodb & Robomongo: Can't connect (authentication) but because I have a newer version of the client (0.9) which supports SCRAM-SHA-1 this should work.
What am I missing here?
Looks like there's a bug in robobmongo. If I add the user using the console:
db.createUser({user:"mongoUser", pwd:"***", roles:["userAdminAnyDatabase"]})
Authentication works. But I now get an error from robomongo:
when I try and expand the list of users in admin.

Caching configuration in ZF2 & Doctrine 2

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.

How do I revert from generate:resource while using JeffreyWay/Laravel-4-Generators?

How do I revert from generate:resource while using JeffreyWay/Laravel-4-Generators ?
Is there a shortcut to remove the installed resource through a command, something like the inverse of the statement below ?
php artisan generate:resource post --fields="title:string, body:text"
I have successfully installed & created a resource using the generator in https://github.com/JeffreyWay/Laravel-4-Generators and watching the tutsplus video https://tutsplus.com/lesson/running-migrations/
There is no shortcut - you need to remove the files manually. If you are using Git (or similar version control) you can just 'roll back'.
Otherwise you need to delete:
Post Migration table creation
Model/Post.php
Views/Posts/*
Controllers/PostController
Seeds/PostsTableSeeder.php
Tests/Controllers/PostsControllerTest.php
Remove postseeding from databaseseeder.php
Update routes.php to remove Route::resource('posts');

Fatal error: Class 'Category' not found after PHP version upgrade

I use CodeIgniter 2.1 and my production server was updated to PHP 5.4.3-1, and the pages that uses phpactiverecord don´t show nothing and don't show any error.
In my test servers with 5.3.6 works fine.
I use the nightly build version of May 2012. I try with the older versions and stable version.
Php-activerecord don´t work fine with php 5.4.3?
EDIT: I found that my new server doesn´t have displays_errors = ON. After activate it, I see the error:
Fatal error: Class 'Category' not found in /srv/www/framework/application/controllers/categories.php on line 26
at line 26:
$data["categories"] = Category::findby($parent_id);
categories.php exists in /srv/www/framework/application/controllers/ and this works fine on PHP 5.3.6.
I need to call something more or call at a different way?
I found the solution.
This solution is for php-activerecord through the latest SPARKS version.
Debugging the autoload_function, I´ve seen that the model file was loaded with the first letter capitalized, only in PHP 5.4.3, not in 5.3.x, and the file wash´t loaded.
Find the ActiveRecord.php at
yourfolder/sparks/php-activerecord/0.0.0.2/vendor/php-activerecord
Search the function:
activerecord_autoload($class_name)
Line 49 change:
$file = $root.DS.$file_name;
for
$file = $root.DS.strtolower($file_name);
And now it works!
p.d. I have found another strange case with PHP 5.4.3 before solve this. The function parse_url() returns false if your database password has a '/' on the string. Because of this, php-activerecord could not connect to the database in the file yourfolder/sparks/php-activerecord/0.0.0.2/vendor/php-activerecord/lib/connection.php at function: file parse_connection_url().
On PHP 5.3 returns the correct array.

Resources