Page 1 of 1

How do libraries work?

Posted: Thu Oct 12, 2006 7:50 am
by impulse()
This question has arose from reading about Swiftmailer. I realise that by using Swiftmailer you don't have to use PHPs mail function. By using Swiftmailer are you creating a new function within PHP so I could now do

Code: Select all

swiftmailer($message, $subject, $to, $from)
That's pseudo by the way.

instead of

Code: Select all

mail($message, $subject, $to, $from)
?

Regards,

Posted: Thu Oct 12, 2006 7:57 am
by feyd
The way libraries work depends entirely on their code. Swift is a class library (for the most part), so most interactions will be with objects. While a library could create functions, many do, they don't necessarily have to do so.

Posted: Thu Oct 12, 2006 10:29 am
by Luke
generally if you want to know how a library works, look at it's documentation.

Posted: Thu Oct 12, 2006 10:42 am
by impulse()
I didn't want to look at Swiftmailers inner-workings or any other libraries inner-workings. I was more curious of what a library in PHP actually was and why you needed them. It's become clear now though.
From what I understand you can import classes from libraries and create functions with libraries. If that isn't right it better be close :)

Posted: Thu Oct 12, 2006 11:04 am
by Luke
Please visit the link I posted. Usually libraries will have documentation... and the documentation will tell you EXACTLY how to use the library. Libraries are just packaged functionality. Swiftmailer allows you to send emails with attachments, smtp authentication, and much more... all of which , d11wqt has generously documented for you at the link I posted. It does not tell you the "inner-workings". It tells you how to use the library.

Posted: Thu Oct 12, 2006 12:08 pm
by Chris Corbyn
To define what a library is if that's what you mean, I'll take a stab at it:

A group of files containing objects and/or functions to provide an interface to extended functionality in a programming language. Libraries usually consist of several components which, when working together can make development of specific functionality in application more efficient.

For example (since you've chosen to mention swift) Swift Mailer consists of various categories of objects:

* The Core class
* Connection interfaces
* Authentication Mechanisms
* Plugins

Put them toegther and that's the library.