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
Aniki
Mar 21, 2001

Wouldn't fit...

Aniki posted:

Edit: Fixed. I'll explain the fix in another post.

I am using Laravel 5 and have been using requests for validation via dependency injection. It has worked fine when I've used one form/request per page, but I'm currently working on a page that has two forms (CC and Check entry) each with their own request injected for validation. Each form with validation works fine independently, but when they are included on the same page, I am finding that both forms are being routed to OrdersController@postOrderStep5NewCC and are having the credit card validation applied to them. Interestingly, if I switch the order that the routes are listed and list OrdersController@postOrderStep5NewCheck last, then both forms are routed to that function and have check validation applied to them.

Below is the relevant code. I tried to keep everything as simple as possible, so the issue would be clear to understand. It seems to be a problem with my routes file, but I'm not sure what I am doing wrong:

routes.php
OrdersController.php
orderStep5.blade.php // I would normally hide one of the forms and toggle between the two forms with jQuery
OrderStep5NewCCRequest.php
OrderStep5NewCheckRequest.php


Ok, I figured out the issue. You can't have multiple actions of the same type directed to a POST or GET request. So a GET and a POST request to the same route is fine, but two POST requests to the same route, even if they are directed to different functions, will cause a conflict. Below is an example of working route code:

php:
<?
Route::get('/orders/orderStep5', 'OrdersController@getOrderStep5');
Route::post('/orders/orderStep5/newCheck', 'OrdersController@postOrderStep5NewCheck');
Route::post('/orders/orderStep5/newCC', 'OrdersController@postOrderStep5NewCC');
?>
This code works because the two POST requests are directed to different routes, so they no longer conflict with/overwrite each other. This issue would occur in Laravel 4 or 5 and I found the answer once I changed my search terms.

http://stackoverflow.com/questions/17338237/laravel-4-multiple-forms-on-same-page

Aniki fucked around with this message at 22:42 on Mar 31, 2015

Adbot
ADBOT LOVES YOU

pepito sanchez
Apr 3, 2004
I'm not mexican
New to PHP and before I make a big mistake I have a couple of stupid questions:

I already have mySQL installed. I want to install Wampserver, with an older version of mySQL as part of the package. There are no options or auto-detection of installed software.

Will there be any conflict if I installed Wampserver and have two instances and versions of mySQL? I'm assuming it's a whole separate service with no conflict?

I've searched online, but it's mostly people just trying to import current databases into their Wampserver's DB. I really don't want to uninstall my newer mySQL now because it comes with a lot of things used by other development environments. I just have doubts, like whether it'll know which service I'm using if I log in through the console. It seems to be dependent on the folder. Dumb questions but I've never been forced to have two installs of similar database software before.

hayden.
Sep 11, 2007

here's a goat on a pig or something

Aniki posted:

I would prefer to not store/handle any payment information, but this company changes processing banks and payment gateways frequently and relies heavily on recurring billing, so as much as I'd like to just store an encrypted reference number, it would cause too many problems on their end.

I am planning on using Stripe's jquery.payment.js for front-end validation, the Laravel requests instances would be for the backend validation (obviously more thoroughly validated than what I provided), and all payment information would be encrypted in the database. It's not ideal, but I don't see them settling on one gateway or processing bank, since they are always looking for someone with better rates or more favorable terms and storing payment info by reference causes problems for recurring payments and refunds.

Don't you have to worry about being PCI compliant the second you touch card info?

spacebard
Jan 1, 2007

Football~

hayden. posted:

Don't you have to worry about being PCI compliant the second you touch card info?

Yep. Pretty clearly D since January of this year. Even without passing cardholder data through a form submit a site's still A:EP.

Aniki
Mar 21, 2001

Wouldn't fit...

spacebard posted:

Yep. Pretty clearly D since January of this year. Even without passing cardholder data through a form submit a site's still A:EP.

Someone else handles PCI compliance and they are fully compliant, but I'm not sure on which standard. As for the application, it will be used in a call center setting by sales agents and will not be accessible to the public. If it were accessible to the public, then at least one of our merchants would require us to use their portal for entering payment info and processing requests. I'd prefer to let the merchant deal with payment entry, validation, and processing, but I don't see that happening at this time, so all I can do is take steps to make that process as secure as possible, which is a big part of why I'm using Laravel, since they have built in CSFR protection, SQL injection projection, encryption, validation, and an auth/permissions system to further restrict who can access or enter payment info. I know it's not ideal for me to handle this on my own even with a framework, but that's all I can do for now and the system will be built so that they can easily switch to using the merchant's portals if that becomes a requirement.

Hughmoris
Apr 21, 2007
Let's go to the abyss!
The OP is going on about 7 years old at this point. Is there a recommend book for beginners wanting to learn PHP? Just as a hobbyist, not needing it for work.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
I can't help with an actual book, but books will help you learn the language and a methodology, usually with an arbitrary CMS-esq goal using approah Y.
Do you actually want to build a specific thing? Do you have any prior experience or knowledge in other languages or with PHP itself?

Depending on your starting position, it might be OK for you to pick a suitable framework for whatever task you want to accomplish and focus your learning there.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
Is the book Easy Laravel 5 any good? I've worked with low-medium level PHP before and used the more basic Laravel 4 elements but it looks like they've introduced a lot of new stuff in 5 and if I do work with it I would like to make use of their smartypants solutions rather than just slapping my meatfists around to make things work. Is it worth the $15?

Sulla Faex fucked around with this message at 17:57 on Apr 8, 2015

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Sulla-Marius 88 posted:

Is the book Easy Laravel 5 any good? I've worked with low-medium level PHP before and used the more basic Laravel 4 elements but it looks like they've introduced a lot of new stuff in 5 and if I do work with it I would like to make use of their smartypants solutions rather than just slapping my meatfists around to make things work. Is it worth the $15?

I was curious so I did some Googling and found this discussion: http://laravel.io/forum/02-10-2015-easy-laravel-5-book-is-it-worth-getting

I'm inclined to agree with the general sentiment there that you're better off using Laracasts or something.

Centripetal Horse
Nov 22, 2009

Fuck money, get GBS

This could have bought you a half a tank of gas, lmfao -
Love, gromdul
So, I did "composer install...," and, "laravel new...," and then I sat there being confused for a while, because I didn't know Laravel 5 had happened. Holy cow is the information on Laravel 5 schizophrenic. There seems to be an awful lot of mixing-and-matching going on with the "old" style and the new.

I have a controller and a Request. I finally figured out how to do customized validation in the Request (although I am almost certainly doing it wrong, since my method is a hodgepodge of what I could pull together from the official documentation and the forums.) I am also using route model binding with this controller, so that /edit/{blah} automatically loads the model with id {blah}, and passes it to my controller. Now, I would like to access the {blah} model inside my Request class. In the controller, it's a snap. I just type-hint like so

code:
public function MyControllerFunction(\App\Models\MyModel $myModel) {
  // Useful stuff goes here
}
That doesn't fly in the Request class, though. Rather than duplicating a bunch of code and using two Request objects, I would like to have the Request behave differently depending on whether or not a model has been loaded. If a model has been loaded by the route model binding, we're validating an edit, and not a creation. Even if I broke it into two Requests, I would like to be able to access the {blah} model inside the Request. I know I can check the form method to distinguish between a create and an edit (POST vs a simulated PATCH, for instance), but I want to access the actual model the way I do in the controller. I have found that the {blah} model is hiding in

code:
$this->route()->parameters()["blah"]["original"]
and

code:
$this->route()->parameters()["blah"]["attributes"]
but that is obviously insane and not how I am supposed to access it. Also, even when I change the form data, both of those show the old model data when I dd() them from inside the Request.

So, am I supposed to be able to access the {blah} model inside the Request? I can get to it just fine in the controller, but I want to use it in the request for validation purposes.

Short version: can I inject or access a model from inside a Request object the same way I can when I use (\App\Models\MyModel $myModel) inside a controller?

Edit: Maybe I really am supposed to use $this->route()->blah? That seems kind of bad.

Centripetal Horse fucked around with this message at 12:31 on Apr 15, 2015

Depressing Box
Jun 27, 2010

Half-price sideshow.
It makes a little more sense if you consider how the route binding is just swapping out the contents of a route parameter with an instance of the Model. Here's an example from a project I'm working on:

PHP code:
<?php

use App\Contracts\Form\Form;
use App\Http\Requests\Request;

class UpdateSubmissionRequest extends Request
{
    public function authorize()
    {
        if ( ! $this->user()->hasPermission('submission.edit')) {
            return false;
        }

        /** @var Form $submission */
        $submission = $this->route()->parameter('submission_id');
        $personId = $this->user()->getPerson()->getId();

        if ($personId !== $submission->getSubmittedBy()) {
            return false;
        }

        return true;
    }
}

hayden.
Sep 11, 2007

here's a goat on a pig or something
Any guesses why my site is loading so slow? http://www.besiegedownloads.com/

It seems like it's not the actual loading of resources that's taking forever, it's just the "first byte" time that's slooow. It's on DigitalOcean and the resource graphs are fine, it's at like 50% CPU and plenty of free memory.

hayden. fucked around with this message at 21:29 on Apr 18, 2015

Impotence
Nov 8, 2010
Lipstick Apathy
How heavy use is it? If you are default-configured the PHP/Apache, you might have a pool of like 2 php-fpm workers and 10 maxclients on apache or something equally ridiculous.

hayden.
Sep 11, 2007

here's a goat on a pig or something
It has maybe 20-30 people at a time according to Google analytics, like 11k page views per day. Seems pretty low in the grand scheme of things?

wolffenstein
Aug 2, 2002
 
Pork Pro
Are you using anything to cache stuff in memory like Redis or Memcache? Are you using CloudFlare or some other reverse proxy/CDN to offload the server?

I'm guessing the "first byte" problem isn't even on your end, it seems likely something's happening on DO's end. Probably some site on the same server getting DDOS'd.

Looking at the Safari inspector, you have a few assets that return 404s including unminimized Bootstrap CSS files.

wolffenstein fucked around with this message at 15:36 on Apr 19, 2015

hayden.
Sep 11, 2007

here's a goat on a pig or something
It seems better today, so it does maybe seem like a DO issue? I will transition to a CDN eventually and probably clean up some other stuff eventually too. Just a hobby site for now so I can't dedicate too much time to it.

edit: for anyone curious, the cause of slowness were some super slow mysql queries running on every page. Hooray for being fixed!

hayden. fucked around with this message at 05:56 on Apr 26, 2015

Stephen
Feb 6, 2004

Stoned
Could anyone recommend me a decent SOAP library for PHP? Pear::SOAP isn't supported anymore and the native PHP SOAPClient is buggy garbage.

musclecoder
Oct 23, 2006

I'm all about meeting girls. I'm all about meeting guys.

Stephen posted:

Could anyone recommend me a decent SOAP library for PHP? Pear::SOAP isn't supported anymore and the native PHP SOAPClient is buggy garbage.

Packagist lists some https://packagist.org/search/?q=soap but I've been using the native PHP SOAP client for years without issue so I'm unfamiliar with any of those.

Stephen
Feb 6, 2004

Stoned

musclecoder posted:

Packagist lists some https://packagist.org/search/?q=soap but I've been using the native PHP SOAP client for years without issue so I'm unfamiliar with any of those.

Upon further review, I think I prematurely blamed PHP SOAP. The WSDL loaded fine in my other applications, but I guess PHP SOAP is more strict regarding parsing which is why I thought it was a PHP fault.

itskage
Aug 26, 2003


I'm actually having a problem I started looking into at the end of the day yesterday with the PHP SoapClient. Trying to extend it from inside of a namespace. It's possible I'm not familiar enough with PHP namespaces and its global classes, but the basic situation looks like this:

code:
<?php namespace address;

  class street {

   }

  // etc

  class address extends \SoapClient {

    private static $classmap = array(
      'street' = > 'street'
      // etc
     );

    public function address ($wsdl = $wsdl_url, $options = array(
      "trace" => 0,
      "exception" => 0,
      "login" => $login,
      "password" => $password,)) {
      foreach(self::$classmap as $key => $value) {
                if(!isset($options['classmap'][$key])) {
                    $options['classmap'][$key] = $value;
                }
            }
            parent::__construct($wsdl, $options);
      }
  }
So now when it runs I'm getting:

quote:

SoapClient::SoapClient() [<a href='soapclient.soapclient'>soapclient.soapclient</a>]: Invalid parameters Line: 19 File:address.php

If I remove the name space it runs fine. If I remove the \ from SoapClient then it looks for SoapClient within the namespace and throws an error. Some googling suggests I can take off the \ and then at the top declare an alias. use \SoapClient as SoapClient but that gives me the same error about parameters. (which makes sense).

The problem seems to be that the $wsdl parameter isn't being passed correctly. It even confuses php storm. From where I'm calling it:

code:
include_class('address.php');

$client = new address\address();
PHP Storm is telling me that it's missing the required $wsdl parameter... but I have that parameter defaulting.

So either it's something stupid with the $wsdl parameter, or the $classmap is getting screwed up in the name space as well. Most of this was done with wsdl2php and was okay until we realized that some of the services use the same names for classes and it was causing issues if you used them within the same scope.

Impotence
Nov 8, 2010
Lipstick Apathy
is $wsdl_url actually set or accessible from that?

itskage
Aug 26, 2003


Yeah in the actual code I'm setting it there, a la $wsdl = "http://x.com/address.svc/wsdl"

I just tried new address\address("http://x.com/address.svc/wsdl"), just to see what happens, but now I'm getting an "Unauthorized Line" error. The line it references is the return line on the function I'm actually using. Very odd.

Edit: I put a break point on the foreach in the address constructor. If I don't pass the wsdl manually like so: new address\address() then it never even hits the for each. If I remove the namespace, take the \ out, and then call new address() it hits the for each.

It's kind of like when I'm using the namespace and going address extends \SoapClient then the public function address isn't actually being recognized as my constructor/new method.

Fake edit: Googled after typing that out and it looks like it my be a php version issue.

http://php.net/manual/en/language.oop5.decon.php

quote:

<?php
namespace Foo;
class Bar {
public function Bar() {
// treated as constructor in PHP 5.3.0-5.3.2
// treated as regular method as of PHP 5.3.3

So we're above 5.3.3 so this makes sense... But then why the hell does it work at all? Unless that part is only true when using namespaces?

Edit2: Yup!

quote:

For backwards compatibility, if PHP 5 cannot find a __construct() function for a given class, and the class did not inherit one from a parent class, it will search for the old-style constructor function, by the name of the class. Effectively, it means that the only case that would have compatibility issues is if the class had a method named __construct() which was used for different semantics.

Unlike with other methods, PHP will not generate an E_STRICT level error message when __construct() is overridden with different parameters than the parent __construct() method has.

As of PHP 5.3.3, methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn't affect non-namespaced classes.


Edit3: Still getting bodied by namespaces. Any attempt to return a value from the extended SoapClient results in it not being able to find the class to return.
Using the example I have above. Say on the address class I have a function that returns the street class:

code:

	/*
         * @param parms $parameters
         * @return street
         */
        public function getStreet(parms $parameters) {
            return $this->__soapCall('getStreet', array($parameters),       array(
                    'uri' => 'http://schema.com/services',
                    'soapaction' => ''
                )
            );
        }
I will get "Class 'street' not found" probably because working on the extended SoapClient does something when it's checking the datatype to return and uses the global namespace for that. gently caress.

itskage fucked around with this message at 15:32 on May 1, 2015

Aniki
Mar 21, 2001

Wouldn't fit...
I am trying to add a Google Geocoder package to a Laravel 5 project and I don't seem to be having much success. I started out by trying to configure this package. I followed all of the instructions detailed in the document and added Google Geocoding API key that I created.

I setup a very basic demo inside of an existing controller as well as the routing:

php:
<?
namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class TestController extends Controller {
    public function getAddress()
    {
        $param = array(
            "address"=>"76 Buckingham Palace Road London SW1W 9TQ",
            "components"=>"country:GB"
        );
        $reponse = Geocoder::geocode('json', $param);

        dd($reponse);
    }
}
?>
When I try running it, I get the following error:

quote:

1/1
FatalErrorException in GoogleGeocoder.php line 71:
Call to undefined function Alexpechkarev\GoogleGeocoder\curl_init()

The line in question is located inside of a protected function. I am wondering if I need to import Geocoder when I call that function or if I need to do some sort of namespace call in the controller. I did find it odd that in the instructions, they didn't mention anything about creating an alias, but even if I add one:

php:
<?
'aliases' => ]
             ...
             'Geocoder'  => 'Alexpechkarev\GoogleGeocoder\Facades\GoogleGeocoderFacade',

],
?>
It doesn't seem to make a difference. I haven't really used packages before, so I assume that I am missing something basic.

I had also looked into a different Geocoder package and the problem that I run into with that one is that when I run:

quote:

sudo php artisan vendor:publish --provider="toin0u/geocoder-laravel"

It returns a message stating, "Nothing to Publish" and it does not create the config/geocoder.php file that it is supposed to. I thought maybe it was a permissions issue, so I got of the project and ran sudo chown [account-name] [project-name] -R and that had no impact.

It seems like if I am running into issues with two packages, then it seems like I am missing something fundamental about using packages in Laravel. Has anyone used either of these Geocoder packages and/or have suggestions for what I could try to get them working properly? I am currently trying the first package and made sure to all references to other package in the code and then ran sudo composer update to remove the files from the vendor directory.

Edit: For the first package, do I need to try and do some sort of method injection like you would for adding a request object? e.g. public function test(Request\test $request)

Aniki fucked around with this message at 00:30 on May 5, 2015

McGlockenshire
Dec 16, 2005

GOLLOCKS!

quote:

FatalErrorException in GoogleGeocoder.php line 71:
Call to undefined function Alexpechkarev\GoogleGeocoder\curl_init()
The wording there is a red herring - there's nothing wrong with your code. You don't have the curl extension installed, and the library has a hard dependency on it but doesn't list it in the composer.json. File a bug with the library author to fix their requirement list, and then go install curl.

Aniki
Mar 21, 2001

Wouldn't fit...

McGlockenshire posted:

The wording there is a red herring - there's nothing wrong with your code. You don't have the curl extension installed, and the library has a hard dependency on it but doesn't list it in the composer.json. File a bug with the library author to fix their requirement list, and then go install curl.

Thank you, I will file a bug report and install cURL in the morning. It would have never occurred to me that cURL wasn't installed, since it seems like such a standard PHP feature.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.

itskage posted:

I will get "Class 'street' not found" probably because working on the extended SoapClient does something when it's checking the datatype to return and uses the global namespace for that. gently caress.
I don't know if this is useful to you or not because there was so little to go on, but here's something:
http://stackoverflow.com/questions/4807171/php-soapclient-example-using-typemap-option

hayden.
Sep 11, 2007

here's a goat on a pig or something
Not really strictly a PHP question, but I was getting this error message (according to logs) since 6 hours ago on my site:

Could not connect: Too many connections

No pages were being served at all. The issue wasn't too much traffic causing too many connections since no pages were being served. I did a simple restart of apache and mysql and it cleared right up.

Most Google results are people saying increase the max number of connections, which I previously already did. What should I be looking for as the actual cause of this, though?

Impotence
Nov 8, 2010
Lipstick Apathy

hayden. posted:

Not really strictly a PHP question, but I was getting this error message (according to logs) since 6 hours ago on my site:

Could not connect: Too many connections

No pages were being served at all. The issue wasn't too much traffic causing too many connections since no pages were being served. I did a simple restart of apache and mysql and it cleared right up.

Most Google results are people saying increase the max number of connections, which I previously already did. What should I be looking for as the actual cause of this, though?

Need to know what this is from. mysql? apache? your own webapp?

Is apache returning a 503 or something? Are you passing through an error from mysql?

hayden.
Sep 11, 2007

here's a goat on a pig or something
It's a web app I made using MySQL and PHP. I have a piece of PHP that was displaying it:

if (!$con) {
die('Could not connect: ' . mysql_error());
}

right after trying a mysql_connect() (yeah yeah it's deprecated I know).

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

hayden. posted:

It's a web app I made using MySQL and PHP. I have a piece of PHP that was displaying it:

if (!$con) {
die('Could not connect: ' . mysql_error());
}

right after trying a mysql_connect() (yeah yeah it's deprecated I know).

I'm guessing you are hitting the mysql connection limit. You can increase this, but I don't think that's the best course of action.

My guess is that you are failing to properly close the connection in your custom app, so you are leaking connections and eventually you run out.

The bandaid for now, as you found, was to simply restart MySQL.

hayden.
Sep 11, 2007

here's a goat on a pig or something
Would it only rarely "leak" one though? Because the site has been working fine for months without this issue.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
Really depends on the exact setup and usage. You might have only just hit the connection pool limit, or it might be only one operation that results in a hanging connection.
You can find out if fletcher is right though, by running this command on the server:
code:
SHOW PROCESSLIST
If you have run away connections, you'll see a growing list of results with entries that never clear. In my experience, the ID should increment for every new process since last restart.

Edit:
If that is the problem, see this SO post for a basic implementation of closing mysql_connect connections during destruct: http://stackoverflow.com/questions/17450971/too-many-connections-error-due-to-many-sleep-connections
Alternatively upgrade to PDO, which I would recommend you do right now. Every second you learn something related to mysql_connect is a second wasted.

v1nce fucked around with this message at 04:05 on May 5, 2015

hedgecore
May 2, 2004
Is PHPBB still the general go-to solution for message boards?

Impotence
Nov 8, 2010
Lipstick Apathy

hedgecore posted:

Is PHPBB still the general go-to solution for message boards?

phpbb 3.1 is actually very very nice: https://www.phpbb.com/about/launch/

don't use any older version; ANYTHING below 3.1 - they're all poo poo

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
PhpBB has a high popularity, mostly because it was the first thing on the market. It's still popular because the code is simpler, which can sometimes be limiting.
SMF in my experience is better (edit: than PhpBB2) in most aspects. The downside is that plugins work by editing core files, which is a dogshit system that causes eternal pain during maintenance.
MyBB is apparently the new hotness. I know nothing about this one, but glancing at the code it looks like a reasonable middle ground with slightly less awful code.

I'd recommend you set up a webserver locally, then install all 3 and see which makes you least angry. Should only eat a few hours.

Fake edit:
Why are all forum controllers just a dump of code? Have these people never heard of event or service architecture? Modularisation? :(

Impotence
Nov 8, 2010
Lipstick Apathy
I mean that poo poo has to run on PHP 5.1 or whatever godawful trash $1/m indian cpanel hosts use without any idea what sysadmining is

I currently use Discourse - http://discourse.org/ in production on many of my sites for a forum. It's absolutely amazing, but this is a PHP thread, so not php. Also it doesn't work on shared hosting or OpenVZ, but that's just as well because it is incredibly heavy on resources.

v1nce
Sep 19, 2004

Plant your brassicas in may and cover them in mulch.
You could make the same argument for the way half of Wordpress was global function-based so it ran on PHP4, but seeing as the current minimum supported version of PHP is 5.4 (security fixes only) then perhaps as a matter of responsibility people should stop writing code targeted at versions lower than that.

Not to mention that the tools needed to make architecture more MVC/Service/Event/Modular have been around since at least PHP 5.0 (2004).

This kind of thing just makes me despair.

Impotence
Nov 8, 2010
Lipstick Apathy
I run 5.6.99-hhvm and often do strongly typed PHP, so :v:

itskage
Aug 26, 2003


v1nce posted:

I don't know if this is useful to you or not because there was so little to go on, but here's something:
http://stackoverflow.com/questions/4807171/php-soapclient-example-using-typemap-option

Thanks for this. It lead me in the right direction.

So basically my example above should have been:

code:
class address extends \SoapClient {

    private static $classmap = array(
      'street' = > 'address\\street'
      // etc
     );
Where the 'street' => 'street' mapping is prefixed with the address namespace. That's all there was to that.

Going to say I was not happy at first because that is a lot of updating to do. The just one of the 6 WSDL classes I need to update has 181 types on the classmap. But the I saw that I can actually run the wsdl2phpgenerator with a namespace flag and it will do this for us.

So this was kind of a pointless endeavor, but at least now I'll understand everything that's happening, including the quirks.

Adbot
ADBOT LOVES YOU

Experto Crede
Aug 19, 2008

Keep on Truckin'
I have a class which has a function in it that puts an array in memcached.

At the start of the function I'm using creating a memcached object with:

code:
$m = new Memcached();
$m->addServer('localhost', 11211);
This obviously means that every time the function is run that it will run the addserver() function.

Aside from it feeling a bit messy, will this cause problems? Is PHP smart enough to see that localhost is already a memcache server it's using? Or will I end up with a huge "pool" that consists of only one server repeated multiple times?

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