Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread tamouse mailing lists
Back to the OP's request, Ken Pugh's "Interface Oriented Design" goes quite
a long way in describing OO* and directly to the heart of why interfaces
make so much sense as a way of designing your code. It does not show PHP
examples, it tries to remain agnostic to language.


Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Dan Joseph
Hey Guys,

Thanks for all this good information so far.  I'll keep you posted on my
edumacation!

-Dan


On Thu, May 16, 2013 at 11:16 PM, Larry Garfield wrote:

> On 05/16/2013 06:45 PM, Tedd Sperling wrote:
>
>> Thanks to both Bastien and Sebastian:
>>
>> While I understand that an interface is like an abstract Class, in that
>> you don't have to flesh-out your methods, but rather where you define
>> exactly how Classes who implement that interface will be required to
>> flesh-out those methods. But so what? What's the point?
>>
>> Without giving me complicated examples, just give me one simple example
>> that illustrates the advantage of using an interface over writing a new
>> Class where you flesh-out whatever methods you want. After all, an
>> interface requires the same thing, does it not?
>>
>> As such, I just don't see the advantage interfaces bring.
>>
>> Cheers,
>>
>> tedd
>>
>
> Practical example, PSR-3:
>
> https://github.com/php-fig/**fig-standards/blob/master/**
> accepted/PSR-3-logger-**interface.md
>
> Say you're writing a stand-alone library, maybe a Twitter-connecting
> library.  You want to be able to log stuff, but don't want to have to deal
> with opening log files yourself.  You also want to allow your library to be
> used by people running Symfony, Code Igniter, Drupal, Zend Framework, or
> PHPBB, all of which have their own logging systems in place that may talk
> to syslog, a database, files on disk, or whatever.  People using those
> frameworks don't want your library spewing log files all over their file
> system.
>
> Instead, you simply support the PSR-3 logging interface.  You accept an
> object that implements that interface in your constructor, and then write
> to it.  What happens on the other side?  Who gives a damn!
>
> For your own testing, you can write a simple class that implements that
> interface and dumps log messages to disk.
>
> When someone uses your library with Symfony, they just pass in a Monolog
> object (the logging system used by Symfony), and your code is now logging
> errors to whatever they have Monolog configured to do.
>
> When someone uses your library with Drupal, they just pass in the Drupal
> Watchog logger object (which is being rewritten to use PSR-3 as we speak),
> and now your library is logging errors to Drupal's logging system (which
> could be syslog or a DB table, depending on how the user has their site
> configured).
>
> And you don't give a damn about any of that.  All you care about is that
> you support "any object that matches this interface".  What that object
> does with the messages you send it, and where that object came from, you
> don't have to give a crap about.
>
> Now take that same concept and apply it at a smaller scale, within your
> own project.  Swap out your database-based cache system for a
> memcache-based one.  Your code doesn't change, because it's writing to an
> interface, not to the database.  Swap out your data store with one that is
> used just for testing.  Etc.
>
> That's what interfaces give you.  Loose coupling, and the ability to
> divide-and-conquer... and even let someone else solve problems for you. :-)
>
> --Larry Garfield
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
-Dan Joseph

http://www.danjoseph.me
http://www.dansrollingbbq.com
http://www.youtube.com/DansRollingBBQ


Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Larry Garfield

On 05/16/2013 06:45 PM, Tedd Sperling wrote:

Thanks to both Bastien and Sebastian:

While I understand that an interface is like an abstract Class, in that you 
don't have to flesh-out your methods, but rather where you define exactly how 
Classes who implement that interface will be required to flesh-out those 
methods. But so what? What's the point?

Without giving me complicated examples, just give me one simple example that 
illustrates the advantage of using an interface over writing a new Class where 
you flesh-out whatever methods you want. After all, an interface requires the 
same thing, does it not?

As such, I just don't see the advantage interfaces bring.

Cheers,

tedd


Practical example, PSR-3:

https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md

Say you're writing a stand-alone library, maybe a Twitter-connecting 
library.  You want to be able to log stuff, but don't want to have to 
deal with opening log files yourself.  You also want to allow your 
library to be used by people running Symfony, Code Igniter, Drupal, Zend 
Framework, or PHPBB, all of which have their own logging systems in 
place that may talk to syslog, a database, files on disk, or whatever.  
People using those frameworks don't want your library spewing log files 
all over their file system.


Instead, you simply support the PSR-3 logging interface.  You accept an 
object that implements that interface in your constructor, and then 
write to it.  What happens on the other side?  Who gives a damn!


For your own testing, you can write a simple class that implements that 
interface and dumps log messages to disk.


When someone uses your library with Symfony, they just pass in a Monolog 
object (the logging system used by Symfony), and your code is now 
logging errors to whatever they have Monolog configured to do.


When someone uses your library with Drupal, they just pass in the Drupal 
Watchog logger object (which is being rewritten to use PSR-3 as we 
speak), and now your library is logging errors to Drupal's logging 
system (which could be syslog or a DB table, depending on how the user 
has their site configured).


And you don't give a damn about any of that.  All you care about is that 
you support "any object that matches this interface".  What that object 
does with the messages you send it, and where that object came from, you 
don't have to give a crap about.


Now take that same concept and apply it at a smaller scale, within your 
own project.  Swap out your database-based cache system for a 
memcache-based one.  Your code doesn't change, because it's writing to 
an interface, not to the database.  Swap out your data store with one 
that is used just for testing.  Etc.


That's what interfaces give you.  Loose coupling, and the ability to 
divide-and-conquer... and even let someone else solve problems for you. :-)


--Larry Garfield

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Nick Khamis
interface Shape {
 public double getArea();
}

class Circle implements Shape {
  double radius;
  public Circle(int double radius) {
this.radius = radius;
  }

  public double getArea() {
return (radius * radius * 3.1415);
  }

}

class Square implements Shape {
  double side;

  public Square(int double side) {
this.side = side;
  }

  double getArea() {
return (side * side);
  }
}


Please make an effort to understand polymorphic concepts of OOP as
they are rudimentary. Without that one will never grasp OO Patterns
(Gang of Four).

Ninus.

On 5/16/13, Tedd Sperling  wrote:
> Thanks to both Bastien and Sebastian:
>
> While I understand that an interface is like an abstract Class, in that you
> don't have to flesh-out your methods, but rather where you define exactly
> how Classes who implement that interface will be required to flesh-out those
> methods. But so what? What's the point?
>
> Without giving me complicated examples, just give me one simple example that
> illustrates the advantage of using an interface over writing a new Class
> where you flesh-out whatever methods you want. After all, an interface
> requires the same thing, does it not?
>
> As such, I just don't see the advantage interfaces bring.
>
> Cheers,
>
> tedd
>
>
> _
> tedd.sperl...@gmail.com
> http://sperling.com
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Tedd Sperling
Thanks to both Bastien and Sebastian:

While I understand that an interface is like an abstract Class, in that you 
don't have to flesh-out your methods, but rather where you define exactly how 
Classes who implement that interface will be required to flesh-out those 
methods. But so what? What's the point?

Without giving me complicated examples, just give me one simple example that 
illustrates the advantage of using an interface over writing a new Class where 
you flesh-out whatever methods you want. After all, an interface requires the 
same thing, does it not? 

As such, I just don't see the advantage interfaces bring.

Cheers,

tedd


_
tedd.sperl...@gmail.com
http://sperling.com



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Bastien


Bastien Koert

On 2013-05-16, at 5:28 PM, Tedd Sperling  wrote:

> -Dan:
> 
> I teach this stuff and still don't fully understand the why/when for 
> interfaces.
> 
> Even the guru's I talk with can't give me a good explanation as to what the 
> advantages are in using them. I've done a lot of experimenting and can't see 
> any advantage for them other than grouping different classes together and 
> creating a new data-tytpe.
> 
> Other than that, from my perspective interfaces are mythicode.
> 
> So, if you find a good reference, please let me know.
> 
> Cheers,
> 
> tedd
> 
> 
> _
> 

Tedd,

The best argument I've seen for interfaces is to abstract calling classes to 
avoid binding to a particular framework. Phpmaster was where I saw that.

The idea was that by implementing an interface, the swapping out a framework 
was much simpler since the only code that needed to be written was more the 
interface adapter to the new framework

Bastien
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Sebastian Krebs
2013/5/16 Tedd Sperling 

> -Dan:
>
> I teach this stuff and still don't fully understand the why/when for
> interfaces.
>
> Even the guru's I talk with can't give me a good explanation as to what
> the advantages are in using them. I've done a lot of experimenting and
> can't see any advantage for them other than grouping different classes
> together and creating a new data-tytpe.
>

An interface is like an contract: It doesn't do anything itself, but every
class, that implements it must follow. This isn't only about the signature
of the methods, but also about the semantics, which is ideally described
directly in the methods comment (DocBlocks). On the other hand the class is
completely free on how it fulfill the contract.

For example: A "QueueInterface". It probably defines the signatures for (at
least) "enqueue()" and "dequeue()" and their semantics: "enqueue()"
enqueues an element at the end of the queue and may fail with an
XY-Exception, when the queue is full, "deuqeue()" dequeues an element from
the front of the queue and throws an Z-Exception, when the queue is empty.
An implementing class is free to implement this on top of a database, or an
array, as well as the class is free to extend it with other methods as it
like.

Of course you could implement it as abstract class, but this leads
(instantly, or later) to a mix between contract and implementation details,
that (by the way) should be up to the implementing class anyway.

Now that you have one, or more classes implementing that interface you can
type hint against this contract and only against this one, because it is
better to always hint against the most-simple type the methods requires. In
this example this means: I, the method x(), expect a queue and I am
completely uninterested in how it is implemented, or what other features it
provides, because I don't use them anyway. Now you can give me a
database-cursor, or a wrapped array as long as they _behave_ like a queue
(--> implementing that interface).

As a side effect: Sometimes it is more fail-safe, because if you change
signatures, or add methods, you'll face the errors from wrongly implemented
classes instantly ;)

Oh: And you are not forced to extend a class :) Lets say I have a
"Comparable"-interface and a "User"-Class. Would "Comparable" be a class, I
have to extend it, which makes it impossible to extend any other class and
also the semantic is wrong: A "User" _behaves_ like a "Comparable", but it
_is not_ a "Comparable". (For me implementing an interface is usually more
a "behaves like", "looks like", or "provides", whereas extending a class is
directly a "is a"-relationship).

This said, the difference between an interface and an abstract class is
mostly in the head: An abstract class is in my opinion never such a strict
contract, like an interface, especially because you can always leave the
"contract-only"-restriction by implementing something into the class, what
is then directly inherited by the subclasses.


My 2 cent :) But for me this "idea" works quite fine :D

Regards,
Sebastian



>
> Other than that, from my perspective interfaces are mythicode.
>
> So, if you find a good reference, please let me know.
>
> Cheers,
>
> tedd
>
>
> _
> tedd.sperl...@gmail.com
> http://sperling.com
>
>
>
>
>
> On May 16, 2013, at 11:11 AM, Dan Joseph  wrote:
>
> > Thanks!  This looks like a good start.  Covers some things I have
> questions
> > on.  I like his approach.
> >
> > Now I just need something advanced to continue on after this.  I'd like
> to
> > learn more about extending, interfaces, abstracts, and why/when they
> should
> > be used.
> >
> > Appreciate it!
> >
> > -Dan
> >
> >
> > On Thu, May 16, 2013 at 11:01 AM, Francisco C Soares <
> dotjun...@gmail.com>wrote:
> >
> >> On 05/16/2013 11:55 AM, Dan Joseph wrote:
> >>
> >> Hey Folks,
> >>
> >> I'm looking to refine my PHP 5 OOP skills.  I know the basics,
> understand
> >> patterns, but have clearly missed a few things along the way.
> >>
> >> Do any of you have some real good PHP 5 OOP tutorials/reads bookmarked
> you
> >> could share?  Something other than php.net/oop5.
> >>
> >> Try,
> >> Tente,
> >>
> >> http://www.killerphp.com/tutorials/object-oriented-php/
> >>
> >> Success!
> >> Sucesso!
> >>
> >> ___
> >> Francisco C Soares ( *Junior* )
> >> 403790c89847cdbe5a262146de8fb93139c4
> >>
> >> BLOG dotjunior.blogspot.com
> >>
> >
> >
> >
> > --
> > -Dan Joseph
> >
> > http://www.danjoseph.me
> > http://www.dansrollingbbq.com
> > http://www.youtube.com/DansRollingBBQ
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
github.com/KingCrunch


Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Nick Khamis
OO comes from the heart. You know you have it when everything you look at
turn into objects, attributes, accessors, mutators, and constructors.

When IBM transitioned from functional to OO level programming, they had their
top level engineers walk into a room and tell their employees that 80% of their
employes will not be able to make the transition. Which percent are you?


Ninus Khamis (PhD)

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Tedd Sperling
-Dan:

I teach this stuff and still don't fully understand the why/when for interfaces.

Even the guru's I talk with can't give me a good explanation as to what the 
advantages are in using them. I've done a lot of experimenting and can't see 
any advantage for them other than grouping different classes together and 
creating a new data-tytpe.

Other than that, from my perspective interfaces are mythicode.
 
So, if you find a good reference, please let me know.

Cheers,

tedd


_
tedd.sperl...@gmail.com
http://sperling.com





On May 16, 2013, at 11:11 AM, Dan Joseph  wrote:

> Thanks!  This looks like a good start.  Covers some things I have questions
> on.  I like his approach.
> 
> Now I just need something advanced to continue on after this.  I'd like to
> learn more about extending, interfaces, abstracts, and why/when they should
> be used.
> 
> Appreciate it!
> 
> -Dan
> 
> 
> On Thu, May 16, 2013 at 11:01 AM, Francisco C Soares 
> wrote:
> 
>> On 05/16/2013 11:55 AM, Dan Joseph wrote:
>> 
>> Hey Folks,
>> 
>> I'm looking to refine my PHP 5 OOP skills.  I know the basics, understand
>> patterns, but have clearly missed a few things along the way.
>> 
>> Do any of you have some real good PHP 5 OOP tutorials/reads bookmarked you
>> could share?  Something other than php.net/oop5.
>> 
>> Try,
>> Tente,
>> 
>> http://www.killerphp.com/tutorials/object-oriented-php/
>> 
>> Success!
>> Sucesso!
>> 
>> ___
>> Francisco C Soares ( *Junior* )
>> 403790c89847cdbe5a262146de8fb93139c4
>> 
>> BLOG dotjunior.blogspot.com
>> 
> 
> 
> 
> -- 
> -Dan Joseph
> 
> http://www.danjoseph.me
> http://www.dansrollingbbq.com
> http://www.youtube.com/DansRollingBBQ


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Trying to understand what I've broken to not allow mkdir() to work.

2013-05-16 Thread Richard Quadling
On 16 May 2013 15:42, Karim Geiger  wrote:

> Hi Richard,
>
> On 05/16/2013 04:33 PM, Richard Quadling wrote:
> > Hi.
> >
> > I'm running on a Mac with a Centos VM (via VirtualBox).
> >
> > Was running from from our SVN server.
> >
> > New repo, now running from GIT.
> >
> > The checkout is on my local machine (using Netbeans, LESS, etc.)
> >
> > The VM is running Apache and PHP V5.4.15
> >
> > During the move, I've got some permissions issues, which I simply don't
> > understand enough to a) resolve myself, b) know what to ask for to get
> the
> > right help in solving the issue.
> >
> > I've been told that the permissions on my mac via the shared folder
> through
> > VirtualBox to the Centos setup is where my problem lies. But I don't
> know.
> >
> > Is there anyone who can give me definite help here? I can manually create
> > the directories, but that's just daft.
> >
> > Nothing LOOKS any different between the two repos, but I don't know how
> to
> > tell beyond comparing ls outputs.
> >
> > Any help would be good.
>
> What happens if you're making an ls -la in your Terminal on your SVN
> folder? Could you paste the output? It looks like the owner or
> permissions of the folder aren't correct.
>
> Regards
>
> Karim
>
> --
> Karim Geiger
> Auszubildender Fachinformatiker AE
>
> B1 Systems GmbH
> Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
> GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
>
>
Seems the mounting is the issue.

mount -o nosuid,uid=apache,gid=apache -t vboxsf ccdev /mnt/newbuild

And that has mounted the drive and the mkdir() is working!

And in further looking, my /etc/fstab was trying to mount ccdev to
/mnt/trunk ...

ARGH!!!

Sorry for the noise. I need a beer now!

-- 
Richard Quadling
Twitter : @RQuadling
EE : http://e-e.com/M_248814.html
Zend : http://bit.ly/9O8vFY


Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Dan Joseph
Thanks!  This looks like a good start.  Covers some things I have questions
on.  I like his approach.

Now I just need something advanced to continue on after this.  I'd like to
learn more about extending, interfaces, abstracts, and why/when they should
be used.

Appreciate it!

-Dan


On Thu, May 16, 2013 at 11:01 AM, Francisco C Soares wrote:

>  On 05/16/2013 11:55 AM, Dan Joseph wrote:
>
> Hey Folks,
>
> I'm looking to refine my PHP 5 OOP skills.  I know the basics, understand
> patterns, but have clearly missed a few things along the way.
>
> Do any of you have some real good PHP 5 OOP tutorials/reads bookmarked you
> could share?  Something other than php.net/oop5.
>
>  Try,
> Tente,
>
> http://www.killerphp.com/tutorials/object-oriented-php/
>
> Success!
> Sucesso!
>
> ___
> Francisco C Soares ( *Junior* )
> 403790c89847cdbe5a262146de8fb93139c4
>
> BLOG dotjunior.blogspot.com
>



-- 
-Dan Joseph

http://www.danjoseph.me
http://www.dansrollingbbq.com
http://www.youtube.com/DansRollingBBQ


Re: [PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Francisco C Soares

On 05/16/2013 11:55 AM, Dan Joseph wrote:

Hey Folks,

I'm looking to refine my PHP 5 OOP skills.  I know the basics, understand
patterns, but have clearly missed a few things along the way.

Do any of you have some real good PHP 5 OOP tutorials/reads bookmarked you
could share?  Something other than php.net/oop5.

Try,
Tente,

http://www.killerphp.com/tutorials/object-oriented-php/

Success!
Sucesso!

___
Francisco C Soares ( *Junior* )
403790c89847cdbe5a262146de8fb93139c4

BLOG dotjunior.blogspot.com 


[PHP] A Good OOP Tutorial/Read?

2013-05-16 Thread Dan Joseph
Hey Folks,

I'm looking to refine my PHP 5 OOP skills.  I know the basics, understand
patterns, but have clearly missed a few things along the way.

Do any of you have some real good PHP 5 OOP tutorials/reads bookmarked you
could share?  Something other than php.net/oop5.

Thanks!

-- 
-Dan Joseph

http://www.danjoseph.me
http://www.dansrollingbbq.com
http://www.youtube.com/DansRollingBBQ


Re: [PHP] Trying to understand what I've broken to not allow mkdir() to work.

2013-05-16 Thread Karim Geiger
Hi Richard,

On 05/16/2013 04:33 PM, Richard Quadling wrote:
> Hi.
> 
> I'm running on a Mac with a Centos VM (via VirtualBox).
> 
> Was running from from our SVN server.
> 
> New repo, now running from GIT.
> 
> The checkout is on my local machine (using Netbeans, LESS, etc.)
> 
> The VM is running Apache and PHP V5.4.15
> 
> During the move, I've got some permissions issues, which I simply don't
> understand enough to a) resolve myself, b) know what to ask for to get the
> right help in solving the issue.
> 
> I've been told that the permissions on my mac via the shared folder through
> VirtualBox to the Centos setup is where my problem lies. But I don't know.
> 
> Is there anyone who can give me definite help here? I can manually create
> the directories, but that's just daft.
> 
> Nothing LOOKS any different between the two repos, but I don't know how to
> tell beyond comparing ls outputs.
> 
> Any help would be good.

What happens if you're making an ls -la in your Terminal on your SVN
folder? Could you paste the output? It looks like the owner or
permissions of the folder aren't correct.

Regards

Karim

-- 
Karim Geiger
Auszubildender Fachinformatiker AE

B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537



signature.asc
Description: OpenPGP digital signature


Re: [PHP] Trying to understand what I've broken to not allow mkdir() to work.

2013-05-16 Thread Alain Williams
On Thu, May 16, 2013 at 03:33:53PM +0100, Richard Quadling wrote:
> Hi.
> 
> I'm running on a Mac with a Centos VM (via VirtualBox).
> 
> Was running from from our SVN server.
> 
> New repo, now running from GIT.
> 
> The checkout is on my local machine (using Netbeans, LESS, etc.)
> 
> The VM is running Apache and PHP V5.4.15
> 
> During the move, I've got some permissions issues, which I simply don't
> understand enough to a) resolve myself, b) know what to ask for to get the
> right help in solving the issue.
> 
> I've been told that the permissions on my mac via the shared folder through
> VirtualBox to the Centos setup is where my problem lies. But I don't know.
> 
> Is there anyone who can give me definite help here? I can manually create
> the directories, but that's just daft.
> 
> Nothing LOOKS any different between the two repos, but I don't know how to
> tell beyond comparing ls outputs.
> 
> Any help would be good.

Have you got SELinux switched on ? Try:

ls -lZ

getenforce

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Trying to understand what I've broken to not allow mkdir() to work.

2013-05-16 Thread Richard Quadling
Hi.

I'm running on a Mac with a Centos VM (via VirtualBox).

Was running from from our SVN server.

New repo, now running from GIT.

The checkout is on my local machine (using Netbeans, LESS, etc.)

The VM is running Apache and PHP V5.4.15

During the move, I've got some permissions issues, which I simply don't
understand enough to a) resolve myself, b) know what to ask for to get the
right help in solving the issue.

I've been told that the permissions on my mac via the shared folder through
VirtualBox to the Centos setup is where my problem lies. But I don't know.

Is there anyone who can give me definite help here? I can manually create
the directories, but that's just daft.

Nothing LOOKS any different between the two repos, but I don't know how to
tell beyond comparing ls outputs.

Any help would be good.

-- 
Richard Quadling
Twitter : @RQuadling


Re: [PHP] Saving session to database

2013-05-16 Thread Lester Caine

Matijn Woudt wrote:




On Thu, May 16, 2013 at 10:43 AM, Lester Caine mailto:les...@lsces.co.uk>> wrote:

I'm having a problem with webtrees ... http://webtrees.net/
My copy is running on http://webtrees.lsces.org.uk and you will see that it
is throwing an error relating to the session handling.

Running Apache 2.2.22, PHP5.4.14, MySQL 5.5.31 (
http://lsces.org.uk/phpinfo.__php  )

If I comment out the session_set_save_handler() section of session.php then
I can log in and use the site. Have tried reworking that as a
SessionHandlerInterface without any success. As far as I can see, the
'write' function of the handler is not being called and while there are
various notes about problems with PHP5.4 blocking access to the write and
close functions, none of the fixes I have tried have resulted in a working
setup.

Anybody seen this problem with PHP5.4?


http://lsces.org.uk/hg/__webtrees/file/dcf6ff358108/__includes/session.php#l334

 is
the code that seems to be failing.


What error do you get? I tried loading the site but it shows up fine.
In general, you should post the error message in your email anyway, for two 
reasons:
1) Most people on this list don't bother to open a (terrible slow) website.
2) Archives, so if anyone after you comes up with the same problem, he will be
able to refer to the archives to find his solution.


Been working on this most of the morning without success :(
Faulty version is back up, and showing all the error messages, but basically ...

ERROR 2: session_regenerate_id(): Session object destruction failed
0 Error occurred on in function session_regenerate_id
But I think it's the initial session write that is failing

ERROR 2: session_write_close(): Failed to write session data (user). Please 
verify that the current setting of session.save_path is correct (/var/lib/php5)

0 Error occurred on in function session_write_close

But it should be writing to the database not the file directory.

--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] php extension about php_stream_fopen_tmpfile()

2013-05-16 Thread Matijn Woudt
On Fri, May 10, 2013 at 3:37 AM, Bleakwind  wrote:

> I write a php extension.
> How can I user Zend API do that?
> where can I find some doc about file_handle->handle ?
>


There's not really a place to ask questions for writing extensions, but
most people here will not be able to answer your question, because they
only write PHP code.
The documentation for the Zend API is freely available from their website.
If it is not there, have a look at the source code, the best documentation
around for any product.
If you still have problems with an extension, the best place to ask would
be the PHP internals list, where the PHP devs hang around, but it does
probably require more understanding from your side first.



>
> ZEND_API zend_op_array *(*org_compile_file)(zend_file_handle *file_handle,
> int type TSRMLS_DC);
> ZEND_API zend_op_array *sead_compile_file(zend_file_handle *file_handle,
> int type TSRMLS_DC)
> {
> php_stream *stream;
> char *data_decode;
> int data_decode_len;
>

Neither php_stream_write nor fwrite use the int type, use size_t instead.


>
> /* ... */
>
> /* Zend API Begin: This unsuccessful */
> php_stream *tmpstream;
> if ((tmpstream = php_stream_fopen_tmpfile()) == NULL) {
> php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create
> temporary file.  Check permissions in temporary files directory.");
> php_stream_close(stream);
> return org_compile_file(file_handle, type TSRMLS_CC);
> }
> numbytes = php_stream_write(tmpstream, data_decode, data_decode_len);
> if (numbytes != data_decode_len) {
> php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only %d of %d bytes
> written, possibly out of free disk space", numbytes, data_decode_len);
> numbytes = -1;
> }
> php_stream_rewind(tmpstream);
> /* Zend API End */
>
> /* C Begin: This is OK */
> FILE *tmpstream;
> tmpstream = tmpfile();
> fwrite(data_decode, data_decode_len, 1, tmpstream);
> rewind(tmpstream);
> /* C End */
>
>
So what happens? You haven't shown us any error, crash, etc?

- Matijn


Re: [PHP] Saving session to database

2013-05-16 Thread Matijn Woudt
On Thu, May 16, 2013 at 10:43 AM, Lester Caine  wrote:

> I'm having a problem with webtrees ... http://webtrees.net/
> My copy is running on http://webtrees.lsces.org.uk and you will see that
> it is throwing an error relating to the session handling.
>
> Running Apache 2.2.22, PHP5.4.14, MySQL 5.5.31 (
> http://lsces.org.uk/phpinfo.**php  )
>
> If I comment out the session_set_save_handler() section of session.php
> then I can log in and use the site. Have tried reworking that as a
> SessionHandlerInterface without any success. As far as I can see, the
> 'write' function of the handler is not being called and while there are
> various notes about problems with PHP5.4 blocking access to the write and
> close functions, none of the fixes I have tried have resulted in a working
> setup.
>
> Anybody seen this problem with PHP5.4?
>
> http://lsces.org.uk/hg/**webtrees/file/dcf6ff358108/**
> includes/session.php#l334is
>  the code that seems to be failing.
>
>
What error do you get? I tried loading the site but it shows up fine.
In general, you should post the error message in your email anyway, for two
reasons:
1) Most people on this list don't bother to open a (terrible slow) website.
2) Archives, so if anyone after you comes up with the same problem, he will
be able to refer to the archives to find his solution.

- Matijn


[PHP] Saving session to database

2013-05-16 Thread Lester Caine

I'm having a problem with webtrees ... http://webtrees.net/
My copy is running on http://webtrees.lsces.org.uk and you will see that it is 
throwing an error relating to the session handling.


Running Apache 2.2.22, PHP5.4.14, MySQL 5.5.31 ( 
http://lsces.org.uk/phpinfo.php )

If I comment out the session_set_save_handler() section of session.php then I 
can log in and use the site. Have tried reworking that as a 
SessionHandlerInterface without any success. As far as I can see, the 'write' 
function of the handler is not being called and while there are various notes 
about problems with PHP5.4 blocking access to the write and close functions, 
none of the fixes I have tried have resulted in a working setup.


Anybody seen this problem with PHP5.4?

http://lsces.org.uk/hg/webtrees/file/dcf6ff358108/includes/session.php#l334 is 
the code that seems to be failing.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php