I've been working on this (and the library classes are actually almost done). The basic idea, is the ability to specify an arbitrary backend (aside from just php and FTP) by dropping a class in /libs/j/filesystem/backend/. It works now (I've written backends for php, FTP and SSH/SCP/SFTP so far), but the question I have is about configuration.
Basically, each one of the backends may require different configuration options in global config. For example, FTP requires Host, Port, User, Pass and Path. SSH on the other hand requires Host, Port, Path, and either User/Pass or path to public key file. I would like to store these credentials in an associave array in JConfig, so that you can switch between backends without loosing the config settings. So, the question is, what's the best way to get the backend dependant config options?
One thought I had, was to add a method to each backend ::getConfig which returns an associative array of the params ('name'=>'type'), so ftp would return an array('host'=>'text', 'port'=>'text', etc), then build a JParam object for each backend, and render all of them and use JS to switch to the active backend...
One other difference I've implimented (for discussion), is a pair of checks on each backend. ::enabled() returns if the backend can be used (for example, SSH requires that LibSSH is installed in PHP), and ::check() which actually opens the backend, and checks a known path for existance (basically, makes sure the credentials are good). So this allows us to impliment a fallback (well, it's there already). So if you load the FTP backend, and the credentials are wrong, it'll fall back to php...
I think the JRegistry handler for PHP needs to be able to support second level values and store them in associative arrays. With that functionality this becomes a much easier nut to crack.
- Louis
On Tue, May 13, 2008 at 9:45 AM, Anthony Ferrara <ircmax...@gmail.com> wrote:
> I've been working on this (and the library classes are actually almost > done). The basic idea, is the ability to specify an arbitrary backend > (aside from just php and FTP) by dropping a class in > /libs/j/filesystem/backend/. It works now (I've written backends for php, > FTP and SSH/SCP/SFTP so far), but the question I have is about > configuration.
> Basically, each one of the backends may require different configuration > options in global config. For example, FTP requires Host, Port, User, Pass > and Path. SSH on the other hand requires Host, Port, Path, and either > User/Pass or path to public key file. I would like to store these > credentials in an associave array in JConfig, so that you can switch between > backends without loosing the config settings. So, the question is, what's > the best way to get the backend dependant config options?
> One thought I had, was to add a method to each backend ::getConfig which > returns an associative array of the params ('name'=>'type'), so ftp would > return an array('host'=>'text', 'port'=>'text', etc), then build a JParam > object for each backend, and render all of them and use JS to switch to the > active backend...
> One other difference I've implimented (for discussion), is a pair of checks > on each backend. ::enabled() returns if the backend can be used (for > example, SSH requires that LibSSH is installed in PHP), and ::check() which > actually opens the backend, and checks a known path for existance > (basically, makes sure the credentials are good). So this allows us to > impliment a fallback (well, it's there already). So if you load the FTP > backend, and the credentials are wrong, it'll fall back to php...
> I think the JRegistry handler for PHP needs to be able to support second > level values and store them in associative arrays. With that functionality > this becomes a much easier nut to crack.
> - Louis
> On Tue, May 13, 2008 at 9:45 AM, Anthony Ferrara <ircmax...@gmail.com> > wrote:
>> I've been working on this (and the library classes are actually almost >> done). The basic idea, is the ability to specify an arbitrary backend >> (aside from just php and FTP) by dropping a class in >> /libs/j/filesystem/backend/. It works now (I've written backends for php, >> FTP and SSH/SCP/SFTP so far), but the question I have is about >> configuration.
>> Basically, each one of the backends may require different configuration >> options in global config. For example, FTP requires Host, Port, User, Pass >> and Path. SSH on the other hand requires Host, Port, Path, and either >> User/Pass or path to public key file. I would like to store these >> credentials in an associave array in JConfig, so that you can switch between >> backends without loosing the config settings. So, the question is, what's >> the best way to get the backend dependant config options?
>> One thought I had, was to add a method to each backend ::getConfig which >> returns an associative array of the params ('name'=>'type'), so ftp would >> return an array('host'=>'text', 'port'=>'text', etc), then build a JParam >> object for each backend, and render all of them and use JS to switch to the >> active backend...
>> One other difference I've implimented (for discussion), is a pair of >> checks on each backend. ::enabled() returns if the backend can be used (for >> example, SSH requires that LibSSH is installed in PHP), and ::check() which >> actually opens the backend, and checks a known path for existance >> (basically, makes sure the credentials are good). So this allows us to >> impliment a fallback (well, it's there already). So if you load the FTP >> backend, and the credentials are wrong, it'll fall back to php...
> I think the JRegistry handler for PHP needs to be able to support second
> level values and store them in associative arrays. With that functionality
> this becomes a much easier nut to crack.
> - Louis
> On Tue, May 13, 2008 at 9:45 AM, Anthony Ferrara <ircmax...@gmail.com>
> wrote:
> > I've been working on this (and the library classes are actually almost
> > done). The basic idea, is the ability to specify an arbitrary backend
> > (aside from just php and FTP) by dropping a class in
> > /libs/j/filesystem/backend/. It works now (I've written backends for php,
> > FTP and SSH/SCP/SFTP so far), but the question I have is about
> > configuration.
> > Basically, each one of the backends may require different configuration
> > options in global config. For example, FTP requires Host, Port, User, Pass
> > and Path. SSH on the other hand requires Host, Port, Path, and either
> > User/Pass or path to public key file. I would like to store these
> > credentials in an associave array in JConfig, so that you can switch between
> > backends without loosing the config settings. So, the question is, what's
> > the best way to get the backend dependant config options?
> > One thought I had, was to add a method to each backend ::getConfig which
> > returns an associative array of the params ('name'=>'type'), so ftp would
> > return an array('host'=>'text', 'port'=>'text', etc), then build a JParam
> > object for each backend, and render all of them and use JS to switch to the
> > active backend...
> > One other difference I've implimented (for discussion), is a pair of checks
> > on each backend. ::enabled() returns if the backend can be used (for
> > example, SSH requires that LibSSH is installed in PHP), and ::check() which
> > actually opens the backend, and checks a known path for existance
> > (basically, makes sure the credentials are good). So this allows us to
> > impliment a fallback (well, it's there already). So if you load the FTP
> > backend, and the credentials are wrong, it'll fall back to php...
On Wed, May 14, 2008 at 10:16 AM, Jinx <jjanss...@gmail.com> wrote:
> Agreed, I would try to use JRegistry for this. It was designed > especially to handle these kind of situations.
> Johan
> On May 14, 5:09 pm, "Louis Landry" <louis.lan...@joomla.org> wrote: > > I think the JRegistry handler for PHP needs to be able to support second > > level values and store them in associative arrays. With that > functionality > > this becomes a much easier nut to crack.
> > - Louis
> > On Tue, May 13, 2008 at 9:45 AM, Anthony Ferrara <ircmax...@gmail.com> > > wrote:
> > > I've been working on this (and the library classes are actually almost > > > done). The basic idea, is the ability to specify an arbitrary backend > > > (aside from just php and FTP) by dropping a class in > > > /libs/j/filesystem/backend/. It works now (I've written backends for > php, > > > FTP and SSH/SCP/SFTP so far), but the question I have is about > > > configuration.
> > > Basically, each one of the backends may require different configuration > > > options in global config. For example, FTP requires Host, Port, User, > Pass > > > and Path. SSH on the other hand requires Host, Port, Path, and either > > > User/Pass or path to public key file. I would like to store these > > > credentials in an associave array in JConfig, so that you can switch > between > > > backends without loosing the config settings. So, the question is, > what's > > > the best way to get the backend dependant config options?
> > > One thought I had, was to add a method to each backend ::getConfig > which > > > returns an associative array of the params ('name'=>'type'), so ftp > would > > > return an array('host'=>'text', 'port'=>'text', etc), then build a > JParam > > > object for each backend, and render all of them and use JS to switch to > the > > > active backend...
> > > One other difference I've implimented (for discussion), is a pair of > checks > > > on each backend. ::enabled() returns if the backend can be used (for > > > example, SSH requires that LibSSH is installed in PHP), and ::check() > which > > > actually opens the backend, and checks a known path for existance > > > (basically, makes sure the credentials are good). So this allows us to > > > impliment a fallback (well, it's there already). So if you load the > FTP > > > backend, and the credentials are wrong, it'll fall back to php...
I'm throwing in JParameter (which we maybe should rename to something different, but thats another story) which could do what you want with my proposal and pre-made patch. :-)
> Ideally this would all just work in JRegistry and any option like that > would be much more simple to handle.
> - Louis
> On Wed, May 14, 2008 at 10:16 AM, Jinx <jjanss...@gmail.com > <mailto:jjanss...@gmail.com>> wrote:
> Agreed, I would try to use JRegistry for this. It was designed > especially to handle these kind of situations.
> Johan
> On May 14, 5:09 pm, "Louis Landry" <louis.lan...@joomla.org > <mailto:louis.lan...@joomla.org>> wrote: > > I think the JRegistry handler for PHP needs to be able to > support second > > level values and store them in associative arrays. With that > functionality > > this becomes a much easier nut to crack.
> > - Louis
> > On Tue, May 13, 2008 at 9:45 AM, Anthony Ferrara > <ircmax...@gmail.com <mailto:ircmax...@gmail.com>> > > wrote:
> > > I've been working on this (and the library classes are > actually almost > > > done). The basic idea, is the ability to specify an arbitrary > backend > > > (aside from just php and FTP) by dropping a class in > > > /libs/j/filesystem/backend/. It works now (I've written > backends for php, > > > FTP and SSH/SCP/SFTP so far), but the question I have is about > > > configuration.
> > > Basically, each one of the backends may require different > configuration > > > options in global config. For example, FTP requires Host, > Port, User, Pass > > > and Path. SSH on the other hand requires Host, Port, Path, > and either > > > User/Pass or path to public key file. I would like to store these > > > credentials in an associave array in JConfig, so that you can > switch between > > > backends without loosing the config settings. So, the > question is, what's > > > the best way to get the backend dependant config options?
> > > One thought I had, was to add a method to each backend > ::getConfig which > > > returns an associative array of the params ('name'=>'type'), > so ftp would > > > return an array('host'=>'text', 'port'=>'text', etc), then > build a JParam > > > object for each backend, and render all of them and use JS to > switch to the > > > active backend...
> > > One other difference I've implimented (for discussion), is a > pair of checks > > > on each backend. ::enabled() returns if the backend can be > used (for > > > example, SSH requires that LibSSH is installed in PHP), and > ::check() which > > > actually opens the backend, and checks a known path for existance > > > (basically, makes sure the credentials are good). So this > allows us to > > > impliment a fallback (well, it's there already). So if you > load the FTP > > > backend, and the credentials are wrong, it'll fall back to php...
I agree however I would be hesitant to put another thing into global configuration, especially something like this that I'd really much prefer to see in a dedicated interface. A lot of options for the most part in the global config can't damage your site or make it hard to use beyond the existing FTP ones or database settings. Additionally you comment it would be nice to have a validation, I don't particularly feel that it would be logical to extend global config in this way. The down side is that it would be another place to configure things which is also bad. So its a bit hard as well.
On Wed, May 14, 2008 at 10:09 PM, Louis Landry <louis.lan...@joomla.org> wrote: > I think the JRegistry handler for PHP needs to be able to support second > level values and store them in associative arrays. With that functionality > this becomes a much easier nut to crack.
> - Louis
> On Tue, May 13, 2008 at 9:45 AM, Anthony Ferrara <ircmax...@gmail.com> > wrote:
> > I've been working on this (and the library classes are actually almost > done). The basic idea, is the ability to specify an arbitrary backend > (aside from just php and FTP) by dropping a class in > /libs/j/filesystem/backend/. It works now (I've written backends for php, > FTP and SSH/SCP/SFTP so far), but the question I have is about > configuration.
> > Basically, each one of the backends may require different configuration > options in global config. For example, FTP requires Host, Port, User, Pass > and Path. SSH on the other hand requires Host, Port, Path, and either > User/Pass or path to public key file. I would like to store these > credentials in an associave array in JConfig, so that you can switch between > backends without loosing the config settings. So, the question is, what's > the best way to get the backend dependant config options?
> > One thought I had, was to add a method to each backend ::getConfig which > returns an associative array of the params ('name'=>'type'), so ftp would > return an array('host'=>'text', 'port'=>'text', etc), then build a JParam > object for each backend, and render all of them and use JS to switch to the > active backend...
> > One other difference I've implimented (for discussion), is a pair of > checks on each backend. ::enabled() returns if the backend can be used (for > example, SSH requires that LibSSH is installed in PHP), and ::check() which > actually opens the backend, and checks a known path for existance > (basically, makes sure the credentials are good). So this allows us to > impliment a fallback (well, it's there already). So if you load the FTP > backend, and the credentials are wrong, it'll fall back to php...