# |
Jul 27th 2021, 18:46 |
paolo.bragagni |
I Need or now only dire One tabke and there are not one line logic. The problem Is that i am not able to write a provider... |
# |
Jul 27th 2021, 18:46 |
greg138 |
Is that actually in your environment, or using a `.env` file and importing that? |
# |
Jul 27th 2021, 18:40 |
slackebot2 |
_Mysql_::class,` `],` |
# |
Jul 27th 2021, 18:40 |
mrgrimpy |
Hi, I'm encountering a weird problem today concerning my database configuration. I set an environment variable via fastcgi_param (DATABASE_FOO_URL) in my Nginx configuration containing a DSN string. Here is my entry in Datasources (app.php): `'foo' => [` `'url' => env('DATABASE_FOO_URL'),` `'className' => _Connection_::class,` `'driver' => |
# |
Jul 27th 2021, 18:25 |
vinicius.big |
I'll check this, it seems the way to go! thanks! |
# |
Jul 27th 2021, 18:24 |
vinicius.big |
nice to meet you, Skie! LOL! |
# |
Jul 27th 2021, 18:23 |
skie956 |
You can use cakephp-fixture-factories from the seeds. It uses faker in background, and the nice thing that it can be configured to generate dependent data, with the root level entity. |
# |
Jul 27th 2021, 18:23 |
skie956 |
I am skie ;) |
# |
Jul 27th 2021, 18:22 |
vinicius.big |
Yeah,,, I'm already using Faker. Its a good approach... But I'm lookign for a easy way to create related data. And thats the goal of skie/cakephp-factory-muffin. Here a example of using it. |
# |
Jul 27th 2021, 18:21 |
cnizzardini |
Too bad the cakephp adpater is for 2.x |
# |
Jul 27th 2021, 18:19 |
cnizzardini |
I've heard of it, but never personally used it. |
# |
Jul 27th 2021, 18:18 |
cnizzardini |
@vinicius.big you can try something like this: https://github.com/fzaninotto/Faker |
# |
Jul 27th 2021, 18:10 |
vinicius.big |
yeah... I mean loading testing data, seeding the database. |
# |
Jul 27th 2021, 18:07 |
kevin.pfeifer |
I guess Vinicius Arantes means loading (test-)data into the “live” database. The fixture factories are only usable inside the tests as far as I know |
# |
Jul 27th 2021, 17:56 |
skie956 |
You can take a look into https://github.com/vierge-noire/cakephp-fixture-factories |
# |
Jul 27th 2021, 17:56 |
skie956 |
Wow, I even dont remember i did it. |
# |
Jul 27th 2021, 17:48 |
greg138 |
It came from the database, which is UTF-8, but I'll check this. |
# |
Jul 27th 2021, 17:47 |
kevin.pfeifer |
could be that the è is encoded in something other then UTF-8 |
# |
Jul 27th 2021, 17:46 |
kevin.pfeifer |
have you tried checking the string if its actually a valid UTF-8 string? ```mb_check_encoding($string, 'UTF-8');``` |
# |
Jul 27th 2021, 17:43 |
vinicius.big |
hey folks. There is any plugin/solution to create generate dummy data for my entities? For Cake4. The Real World Example App uses skie/cakephp-factory-muffin but its using Cake 3.8 Other examples on Cake awesome List are still using cake3 also. |
# |
Jul 27th 2021, 16:58 |
greg138 |
I know this is a little old, but I wouldn't think it would cause this sort of issue. |
# |
Jul 27th 2021, 16:58 |
greg138 |
```intl Internationalization support => enabled ICU version => 64.2 ICU Data version => 64.2 ICU TZData version => 2019a ICU Unicode version => 12.1``` |
# |
Jul 27th 2021, 16:53 |
slackebot2 |
(/var/www/cake3/vendor/cakephp/cakephp/src/I18n/Formatter/IcuFormatter.php:56)``` |
# |
Jul 27th 2021, 16:53 |
greg138 |
I'm running into a problem passing a UTF-8 string as a positional parameter in `__`. Anybody else see this? `$text = __('{0} {1} document {2}', $action, $category, $filename);` When `$filename` has something like "123 Des règles", we get ```[Aura\Intl\Exception\CannotFormat] Invalid UTF-8 data in string argument: '123 Des règles': U_INVALID_CHAR_FOUND |
# |
Jul 27th 2021, 16:51 |
greg138 |
If you only ever need the code in one place, then having it in that one place is more elegant; why have a whole separate file just to implement a one-line function? If you need it in multiple places, but all in the same table, then a function in that table is probably most elegant. If you need it across tables, then a provider gets to be a useful thing. |
# |
Jul 27th 2021, 16:13 |
paolo.bragagni |
...and now that I know about providers seems more elegant... :D |
# |
Jul 27th 2021, 16:12 |
paolo.bragagni |
Can I put custom logic in a method? |
# |
Jul 27th 2021, 16:11 |
paolo.bragagni |
Id like to reuse the custom logic |
# |
Jul 27th 2021, 15:59 |
tyler.adam.lazenby |
I finally got my ci to run properly |
# |
Jul 27th 2021, 15:36 |
kevin.pfeifer |
as cnizzardini already said above you don’t need to create a custom provider. Just use this approach: ```$validator->add('title', 'someuniquename', [ 'rule' => function ($value, $context) use ($extra) { // Custom logic that returns true/false }, 'message' => 'The title is not valid' ]);``` Custom Providers are just a tool to separate custom rules into its own file. |
# |
Jul 27th 2021, 15:33 |
paolo.bragagni |
Il try tomorrow. (Someting easier??) |
# |
Jul 27th 2021, 15:00 |
cnizzardini |
Name your class `MyProvider` is the standard |
# |
Jul 27th 2021, 14:59 |
greg138 |
Should be `'provider' => 'custom'`, no? |
# |
Jul 27th 2021, 14:53 |
paolo.bragagni |
no errors but no validator |
# |
Jul 27th 2021, 14:52 |
paolo.bragagni |
class myProvider { public function customMethod() { return false; } } |
# |
Jul 27th 2021, 14:52 |
paolo.bragagni |
in myProvider |
# |
Jul 27th 2021, 14:52 |
paolo.bragagni |
$validator = new Validator(); $validator->setProvider('custom', new \App\Model\myProvider()); $validator->add('descrizione', 'custom', [ 'rule' => 'customMethod', 'provider' => 'table' ]); |
# |
Jul 27th 2021, 14:51 |
paolo.bragagni |
then in my model table in initialize I wrote |
# |
Jul 27th 2021, 14:50 |
paolo.bragagni |
created myProvider.php in App/Model |
# |
Jul 27th 2021, 14:50 |
paolo.bragagni |
no bo |
# |
Jul 27th 2021, 14:48 |
paolo.bragagni |
no wait |