Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Academician Nomad
Jan 29, 2016

Biowarfare posted:

^5 cal nerd

try
ini_set('output_buffering', 0);
ini_set('zlib.output_compression', 0);
ini_set('implicit_flush', 1);


at the top of your php file if you don't have ini access

performance slowdowns apply when you do this afaik, and compression breaks because you're sending it chunk by chunk

Cool beans, thanks!

Adbot
ADBOT LOVES YOU

Experto Crede
Aug 19, 2008

Keep on Truckin'
What is generally considered the best way to write a system that uses modules/plugins?

Basically, I'm planning to write a system that scrapes information from various sources and ideally want it to be modular. The basic idea is that it'll have a central core that'll take the request for information and store the results in the database. To get the data it needs it'll use the modules in a specific folder to get the info it needs that return the data in a consistent format for the central core to process store and display, etc..

But I want to be reasonably automatic, so if I want to get a new source of information, I just write a new module that returns the data in a format the core can understand and the next time it runs it'll also pull information from that new source.

I'm not sure what the best approach is for doing this though, so some input would be appreciated!

bigmandan
Sep 11, 2001

lol internet
College Slice

Experto Crede posted:

What is generally considered the best way to write a system that uses modules/plugins?

Basically, I'm planning to write a system that scrapes information from various sources and ideally want it to be modular. The basic idea is that it'll have a central core that'll take the request for information and store the results in the database. To get the data it needs it'll use the modules in a specific folder to get the info it needs that return the data in a consistent format for the central core to process store and display, etc..

But I want to be reasonably automatic, so if I want to get a new source of information, I just write a new module that returns the data in a format the core can understand and the next time it runs it'll also pull information from that new source.

I'm not sure what the best approach is for doing this though, so some input would be appreciated!

Sound very similar to how Laravels middleware system works. For a naive solution:

PHP code:
<?php

// do some work, etc...

// all modules would implement some interface...
$modules = [
	ModuleOne::class, ModuleTwo::class, ModuleThree::class
];

$results = [];

foreach ($modules as $mod)
{
	$m = new $mod();
	$results[] = $m->run($data_from_scraping);
}


// do something with the results
Then the only thing you would need to change when adding a new module would be to update the array of modules. Ideally this would be wrapped up in some sort of class and have some error handling.

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:
Sooo, updating a server and I see that pdo-oci and oci8 are still as much of a pain in the rear end as ever. I'm being led to believe that pdo-oci is just not a thing anymore, but the app is written with it and I'm not a guy with a lot of time to rewrite. I've gone so far as to try php7 but compiling with pdo-oci fails because of LDAP. Basically, help. What is the current advice on oracle and pdo? Ubuntu 14.04.

Impotence
Nov 8, 2010
Lipstick Apathy
why the hell would you use oracle and php

(maybe mangling some form of odbc?)

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:

Biowarfare posted:

why the hell would you use oracle and php

(maybe mangling some form of odbc?)

Dude, it wasn't my decision. But it worked before.

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS
So, I've been tasked with fixing/altering our website since "I know how to computer".
It's written in php, which I don't know, I barely have a base in python/c++.

It's an admin form where someone can get on and add events or articles. The 'Articles' form works as it is supposed to, the 'Shows' does not.

--
On shows.php:
code:
function newShow() {

  $results = array();
  $results['pageTitle'] = "New Show";
  $results['formAction'] = "new";

  if ( isset( $_POST['saveChanges'] ) ) {

    // User has posted the show edit form: save the new show
    $show = new Show;
    $show->storeFormValues( $_POST );
    $show->insert();
    header( "Location: shows.php?action=shows&amp;status=changesSaved" );

  } elseif ( isset( $_POST['cancel'] ) ) {

    // User has cancelled their edits: return to the show list
    header( "Location: shows.php" );
  } else {

    // User has not posted the show edit form yet: display the form
    $results['show'] = new Show;
    require( TEMPLATE_PATH . "/shows/editShow.php" );
  }
I changed the actions of the else statement and that is what is being executed for some reason.

Here is the articles php:
code:
function newArticle() {

  $results = array();
  $results['pageTitle'] = "New Article";
  $results['formAction'] = "new";

  if ( isset( $_POST['saveChanges'] ) ) {

    // User has posted the article edit form: save the new article
    $article = new Article;
    $article->storeFormValues( $_POST );
    $article->insert();
    header( "Location: articles.php?action=articles&amp;status=changesSaved" );

  } elseif ( isset( $_POST['cancel'] ) ) {

    // User has cancelled their edits: return to the article list
    header( "Location: articles.php" );
  } else {

    // User has not posted the article edit form yet: display the form
    $results['article'] = new Article;
    require( TEMPLATE_PATH . "/articles/editArticle.php" );
  }

}
Does anyone see anything here that would be causing this? or is it in some other file?

Here is the bottom fieldset from editShow.php
code:
<fieldset class="centered">
    <?php if ( $results['show']->id ) { ?>
      <input type="submit" class="button" title="Save changes" name="saveChanges" id="submit" value="Save Changes" onclick="return confirm('Save Changes?')" >
      <input type="submit" class="button" title="Discard changes" name="cancel" id="cancel" value="Discard Changes" onclick="return confirm('Discard Changes?')" formnovalidate>
      <input type="button" class="button" title="Delete Show" id="delete" value="Delete Show" onclick="location.href='shows.php?action=delete&amp;id=<?= $results["show"]->id ?>'; return confirm('Delete This Show?')" >
    <?php } else { ?>
      <input type="submit" class="button" title="Add new show" name="createNew" id="submit" value="Add New Show">
      <input type="submit" class="button" title="Do not add new show" formnovalidate name="cancel" id="cancel" value="Cancel" onclick="return confirm('Discard Changes?')" >
    <?php } ?>
    </fieldset>

I know there is probably some way to rewrite all of this way easier, but I don't have the skill to do all that. I'm hoping it's real easy fix. Your help is much appreciated. Also, edit works fine and delete does as well.

ButtWolf fucked around with this message at 19:33 on Apr 25, 2016

canis minor
May 4, 2011

Your "Add New Show" has name "createNew", while in controller you're expecting "saveChanges". However, if both of these controllers are included in the same place, then having either unique name or value would be the way to go.

Also, it's not part of your question, but bear in mind that everything after header gets evaluated - as such it's recommended to either exit or return after header.

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS
Well that makes it go to the correct page now : shows.php?action=shows&status=changesSaved
but is not updating the list.

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS
I'm still very confused. I've compared the all the files and they look virtually the same.

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS
changed the value in both files to 'addNew'
It takes me back to /shows.php?action=shows&status=changesSaved which is what it is supposed to do, but still is not updating.
This is incredibly frustrating. I don't understand why articles.php works and shows.php does not. It apparently worked at one point, before our web guy quit.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
If the scripts are basically the same, chances are it's not the scripts.

Using chrome? Press F12 and look at the Network tab. Submit the form again. What's in the Headers for the POST request? Does it look correct?

canis minor
May 4, 2011

Can you please paste the file in which newShow is being called? Perhaps you've got validation of $_POST there.

Another thing - are articles and shows stored in different places? Maybe your shows are being saved to articles table (and that's why it's not updating) - you'd have to show us the storeFormValues and insert functions. Looking at the code you've posted, the issue lies elsewhere.

vvv Can you please add the file in which Show class is defined? (Article as well if possible, but really I'd like to see the Show)

canis minor fucked around with this message at 21:44 on Apr 26, 2016

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS
Google docs with all 6 files.
Is this easier?

Thanks for trying to help btw. Normally I just get yelled at a lot cause I'm dumb.

I don't fully understand how all of this works, is probably the main problem. I'm just a quick fix until they hire another web developer, which will be whenever I quit probably.

ButtWolf fucked around with this message at 17:44 on Apr 26, 2016

ButtWolf
Dec 30, 2004

by Jeffrey of YOSPOS
put up 3 more files - Shows.php, Articles, Dealers.php
These are the files with all the class stuff, which is what I need to look at. This is even further beyond me.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
That's because those files are Active Record classes. Active Record is a pretty classic pattern, but it's one that people have grown to dislike, because it contains two concerns: Database access and object data.

If you're not familiar, the class (eg. Dealer) is an Entity, usually represented by one row in the DB.

The public members contain the data for the record:
code:
class Dealer
{
  // Properties
  public $id = null;
  public $name = null;
  public $website = null;
  public $formatted_phone_number = null;
  // .. etc
The public static methods are used to fetch data from the database, for instance:
code:
public static function getById( $id ) {}
This lil' fella just grabs a single Dealer, which is nice.

code:
public static function getList( $state ) { }
This ugly bastard is incorrectly documented, and returns an array of "states" (where supplied, or all states), and a count of the total.
It's not paginated but it does two queries anyway for no reason. Awesome.

Anyway, despite the jankyness of the code, I can't see any problems that could manifest as that particular bug. The fact you're getting the header redirect leads me to believe the PDO insert is silently failing.

Try this:
code:
// shows.php


  public function insert() {
    try {
      // [...]

      // Insert the Show
      $conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
      $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
That'll tell PDO to throw exceptions when it hits any errors. The default is to be silent and let you inspect the error instead.

This could be made hella tidier by not initialising the PDO object and connection for every query, which is super duper backwards retard face.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Not sure where to put this, but I figure you guys in php-land would work with rewrite rules more than most. I'm transitioning a site from an OpenCart install and I need to redirect some of their URLs. Specifically, the brand pages which are structured like so:
domain.com/Brand-Name1?sort=p.model&order=ASC

But can also be:
domain.com/Brand-Name1

They need to be turned into:
domain.com/brands/New-Brand-Name1

So I figured out how to do this, but it feels super inefficient because I'm using >3< rewrite lines per brand, because I have to match/replace for both Brand-Name1 by itself, and also Brand-Name1?sort= with query string, and lastly Brand-Name1 does not equal New-Brand-Name1. This works:
code:
RewriteCond %{REQUEST_URI}  ^Brand-Name1$
RewriteCond %{QUERY_STRING} ^sort=|-n
RewriteRule ^Brand-Name1$ brands/New-Brand-Name1/? [r=301,nc,L]
Is there a better way to do this? Ideally I'd love it if I could just do this:
code:
RewriteRule ^Brand-Name1$ brands/New-Brand-Name1/? [r=301,nc,L]
But the /? operator at the end doesn't work because I haven't accessed %{QUERY_STRING}. I'm also unfortunately on Apace 2.2.25 and can't use QSD but I think it might have the same limitation.

EDIT-Sorry I forgot one thing, the second example "works" in that it will match and redirect, but will leave the query string in the URL, which I don't want.

Scaramouche fucked around with this message at 18:54 on May 10, 2016

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
I'm not an htaccess wizard, but if you can't use QSD (Query String Discard) then you probably can't discard the query string cleanly. You might be able to replace it if you don't use QSA, and provide your own non-empty query string.. but as you said, that doesn't seem to work for you unless you touch %{QUERY_STRING}.

With your current ruleset, only the first example you gave - with the query string - gets matched. That's obviously because of the RewriteCond checking for the query string. That little hack could be made a lot less specific so it works regardless of its presence.

I'm testing this using this htaccess tester, so some aspects may vary from your 2.2.25 installation.

Try this:
code:
# Match any these
RewriteCond %{REQUEST_URI}  ^/Brand-Name1$ [OR]
RewriteCond %{REQUEST_URI}  ^/Brand-Name2$
# AND the QueryString as QSD fudgery
RewriteCond %{QUERY_STRING} .*
# Prepend namespace
RewriteRule ^(.+)$ brands/$1/? [r=301,nc,L]
Here you explicitly pile up your Brand-NameX urls with [OR] conditions, and then you access the totally optional QueryString.
Be sure not to make the last REQUEST_URI an [OR] otherwise it'll match with OR QueryString .* which obviously matches everything ever.

Other options include using RedirectMatch instead, where you just link the URLs and their desired targets. If you had to re-map particular brand names to more friendly URLs (eg. Brand-Name1 becomes brand-name-one) then I'd recommend this route.
code:
RedirectMatch 301 ^/Brand-Name1 [url]http://www.example.com/brands/brand-name-one[/url]
RedirectMatch 301 ^/Brand-Name2 [url]http://www.example.com/brands/brand-name-two[/url]
It's pretty easy to make a PHP script that reads CSV and shits RedirectMatch rules, if you have a lot of them.
Honestly though I'm not sure what the RedirectMatch does to the query string.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Hmm, thanks for that.

Unfortunately I do need to re-map entirely; think going from Xerox-Copy-Machines to just Xerox because the brand also includes Printers, Toner, etc.

Redirectmatch doesn't take the URL into account as far as I can tell:
http://serverfault.com/questions/500961/redirectmatch-and-query-string

I'll do it my janky crappy way I think

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

Scaramouche posted:

Redirectmatch doesn't take the URL into account as far as I can tell:
http://serverfault.com/questions/500961/redirectmatch-and-query-string

.. doesn't that link say that it only takes the URI into account, and not the query string? Isn't that want you want? You only want to discard the query string, yeah?

Other options include:
code:
# Round one: All your lovely rewrite rules.
RewriteRule ^Brand-Name1$ brands/brand-name-one/? [r=301,nc,E=qsd:1,L]
RewriteRule ^Brand-Name3$ brands/brand-name-three/? [r=301,nc,E=qsd:1,L]

# Round 2: When round 1 is hit (Env qsd=1) strip the Query String. This is equivalent to QSD.
RewriteCond %{ENV:qsd} ^1$
RewriteCond %{QUERY_STRING} .+
RewriteRule (.*) $1/? [r=301,nc,E=qsd:0,L]

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

v1nce posted:

.. doesn't that link say that it only takes the URI into account, and not the query string? Isn't that want you want? You only want to discard the query string, yeah?

Other options include:
code:
# Round one: All your lovely rewrite rules.
RewriteRule ^Brand-Name1$ brands/brand-name-one/? [r=301,nc,E=qsd:1,L]
RewriteRule ^Brand-Name3$ brands/brand-name-three/? [r=301,nc,E=qsd:1,L]

# Round 2: When round 1 is hit (Env qsd=1) strip the Query String. This is equivalent to QSD.
RewriteCond %{ENV:qsd} ^1$
RewriteCond %{QUERY_STRING} .+
RewriteRule (.*) $1/? [r=301,nc,E=qsd:0,L]

By only taking the URI into account so far means that querystring will just be ignored (and not discarded), which was the case here with Redirectmatch.

I tried the other option with the variable, but I'm running into another problem. Brand-Name1 is a permalink in the underlying WordPress system I'm using, so stuff with query strings is getting routed to that instead of /brands/brand-name-one for whatever reason, despite using the L directive and having them higher in the file. I'm thinking I'll go with the original 3 line solution, but luckily I got into WebMaster tools, and only about 10 or so of the brands were indexed like that, so it's not nearly as many lines of .htaccess as I had thought.

Thanks for your help though! I didn't know you could do local variables like that within the rewrite rules.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
It's probably related to the regex being overly specific (^Brand-Name1$) , but it's hard to say without seeing it in action. RewriteRules can be incredibly sensitive, and it gets worse when you want selective actions.

But yeah, stem the bleeding at this point and go with what you had, rather than trying to prittify with a solution that isn't working. Just slap a comment at the top explaining why that poo poo code exists, in case someone else ever had to tidy it up.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Has anyone here ever used or heard of a site built with PyroCMS? I started a new job on Monday and my first project is to build a site with this thing. It sounds nice, but there's basically no documentation and no evidence that anyone has ever succeeded at using it. If I can't get any traction tomorrow, I'm going to tell them we need to switch immediately for this project to succeed.

spiritual bypass
Feb 19, 2008

Grimey Drawer

rt4 posted:

Has anyone here ever used or heard of a site built with PyroCMS? I started a new job on Monday and my first project is to build a site with this thing. It sounds nice, but there's basically no documentation and no evidence that anyone has ever succeeded at using it. If I can't get any traction tomorrow, I'm going to tell them we need to switch immediately for this project to succeed.

Update: PyroCMS actually seems really good and the code is well-organized and easy to read, but it still needs documentation

revmoo
May 25, 2006

#basta
When I looked at it I got really excited by it, but then I realized that it doesn't have a whole lot of features.

Not a bad starting point, but very much not turnkey, at least when I was evaluating it.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

v1nce posted:

I'm testing this using this htaccess tester, so some aspects may vary from your 2.2.25 installation.

Thanks for this, I had another rewrite URL thinger and I used this site to figure it out (tried like 3 others and they were useless and then I remembered you recommended one).

Posting here what I did for posterity in case anyone else ever needs to do this.

I was converting all product search URLs from OpenCart to WooCommerce. So the URL had to change from this:
/?route=product/search&tag=BLAH&sort=foo&dir=bar

To this:
/?post_type=product&s=BLAH

Normally straightforward but I hit some hiccups because I kept messing up because there was no actual file name, the whole thing was querystring. This rewriterule solved it:
code:
## product searches
RewriteCond %{QUERY_STRING} ^route=product/search.*tag=([^&]+).*$
RewriteRule ^(.*)$ ?post_type=product&s=%1 [r=301,nc,L]
EDIT-Oh yeah, and that original querystring removal question was solved by just using /? in the rewriterule. turns out there was some caching going on that was making testing hellish.

Scaramouche fucked around with this message at 22:41 on May 20, 2016

spiritual bypass
Feb 19, 2008

Grimey Drawer

revmoo posted:

When I looked at it I got really excited by it, but then I realized that it doesn't have a whole lot of features.

Not a bad starting point, but very much not turnkey, at least when I was evaluating it.

I still don't recommend it, but so far it's not a disaster. I've made a rudimentary theme and some post types inside a module, at least.

nielsm
Jun 1, 2009



Laravel 5:

I'm building a thing and learning the framework as I go. I've just started implementing authorization with the built-in system, with Policy classes, which is pretty neat for permissions tied to specific model instances. But what when I have a permission not tied to any model instances, but is rather global, so to say?
The specific case I have right now is "create new teams", only some users should have that permission. I can't check the permission on an object that doesn't exist yet, how are you supposed to declare that?

DarkLotus
Sep 30, 2001

Lithium Hosting
Personal, Reseller & VPS Hosting
30-day no risk Free Trial &
90-days Money Back Guarantee!

nielsm posted:

Laravel 5:

I'm building a thing and learning the framework as I go. I've just started implementing authorization with the built-in system, with Policy classes, which is pretty neat for permissions tied to specific model instances. But what when I have a permission not tied to any model instances, but is rather global, so to say?
The specific case I have right now is "create new teams", only some users should have that permission. I can't check the permission on an object that doesn't exist yet, how are you supposed to declare that?

You'll check against the user object. So tie that ACL to the user object to see if the user is allowed to create teams.
Something like this:

php:
<?
\Gate::allows('create_teams', $user);
// Or
$this->authorize('create_teams', $user); // requires use of Illuminate\Foundation\Auth\Access\AuthorizesRequests
?>

nielsm
Jun 1, 2009



DarkLotus posted:

You'll check against the user object. So tie that ACL to the user object to see if the user is allowed to create teams.
Something like this:

So essentially use a dummy parameter when nothing else is appropriate? Kinda lovely solution but I guess I can live with it.

poxin
Nov 16, 2003

Why yes... I am full of stars!
Anyone know of a free obfuscator for code? Or is IonCube/ZendGuard kind of the only good options out there?

DarkLotus
Sep 30, 2001

Lithium Hosting
Personal, Reseller & VPS Hosting
30-day no risk Free Trial &
90-days Money Back Guarantee!

poxin posted:

Anyone know of a free obfuscator for code? Or is IonCube/ZendGuard kind of the only good options out there?

Those can be easily reverse engineered, you're better off not obfuscating and instead just license your code with some sort of support agreement as well.
Give users a reason to subscribe, you can never prevent code theft though.

McGlockenshire
Dec 16, 2005

GOLLOCKS!

DarkLotus posted:

Those can be easily reverse engineered, you're better off not obfuscating and instead just license your code with some sort of support agreement as well.
Give users a reason to subscribe, you can never prevent code theft though.

Just to underscore how stupidly ineffective these products are, the wide variety of modern tooling we have now means that any experienced PHP developer can clean up any script that uses a pure-PHP obfuscation without too much effort. The types that require a server-side extension are a little more trouble, but that's nothing that a few dollars thrown at a sketchy Russian cracking service won't take care of.

The effort is simply not worth the end-user annoyance.

If you're only trying to prevent modification of the code, not necessarily piracy prevention, then you want strong wording in your user license agreement, and if you take it seriously, you'll also want a lawyer.

poxin
Nov 16, 2003

Why yes... I am full of stars!

DarkLotus posted:

Those can be easily reverse engineered, you're better off not obfuscating and instead just license your code with some sort of support agreement as well.
Give users a reason to subscribe, you can never prevent code theft though.

Yeah understood. It was more to keep not too savvy people from just opening up the source files and making edits. It's a self-hosted app going to be deployed on a client's server.

DarkLotus
Sep 30, 2001

Lithium Hosting
Personal, Reseller & VPS Hosting
30-day no risk Free Trial &
90-days Money Back Guarantee!

poxin posted:

Yeah understood. It was more to keep not too savvy people from just opening up the source files and making edits. It's a self-hosted app going to be deployed on a client's server.

Just put a legal disclaimer at the top of each file that warns against unauthorized modifications.
It may make them think twice...
Also, McGlockenshire has a good point, implement a good license agreement and make your customers sign something.

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies
What's the best way to unit test a database driver class with phpunit? It uses PDO to connect to a database and then gives us utility functions to the underlying PDO class. Would I always want to hook this up to simple database and straight unit test this or is it generally better to mock the PDO class (and how? Pass in the PDO class to be used?) and then just mock out the necessary functions as necessary?

McGlockenshire
Dec 16, 2005

GOLLOCKS!
Do you use an SQL builder, or are you writing SQL yourself?

Be careful not to reinvent the wheel needlessly. Doctrine DBAL and the query builder it provides so everything you really need, including tests.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul

McGlockenshire posted:

Do you use an SQL builder, or are you writing SQL yourself?

Be careful not to reinvent the wheel needlessly. Doctrine DBAL and the query builder it provides so everything you really need, including tests.

Doctrine facilitates testing? Some of the teams at my workplace use it, but I've only had to dabble in it occasionally. What does it provide for testing?

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
I think McGlockenshire meant that it was already unit tested so you don't have to roll your own code, then test it. Doctrine has already covered this ground, repeatedly.

That said:
It's design lends itself to be easily mockable, so you can test Entities, Repositories and Services in a cleanly isolated manner.
You can couple it with Doctrine Fixtures which helps you build your fixture data, rather than using poo poo like SQL dumps which can become unmanageable.
The entire data model is transactional, so you can (mostly) isolate data during tests, and not affect your data fixtures.

McGlockenshire posted:

Be careful not to reinvent the wheel needlessly. Doctrine DBAL and the query builder it provides so everything you really need, including tests.

Doctrine DBAL doesn't exactly hold your hand, as most people use Doctrine for the ORM, which is a lot more friendly (greater abstraction).
If you're looking for a simple starting point, take a look at the Data Retrieval and Manipulation docs and expand out as you need.

Adbot
ADBOT LOVES YOU

jiggerypokery
Feb 1, 2012

...But I could hardly wait six months with a red hot jape like that under me belt.

I tend to simply version a SQLite db populated with fixtures with a cheeky script to build it, migrate it and populate it for the test suite to use. Don't see the point running data reliant tests without, ya know, data. Mocking dbal seems like a waste of time

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply