cpliakas / simplesamlphp-composer

A Composer-compatible packages.json file for SimpleSAMLphp along with a stupid simple PHP script that generates the file.
GNU General Public License v3.0
4 stars 6 forks source link

How to autoload SimpleSAMLphp classes #4

Open martynbiz opened 9 years ago

martynbiz commented 9 years ago

I'm not exactly sure yet how to use SimpleSAMLphp as a dependancy with composer but I really like the idea. I have some questions:

1) How do I allow classes to be autoloaded. I would rather not have to require _autoload and use composer autoload capabilities if possible. It seems composer is picking up the other dependancies in autoload file, but not this one (even though I'm run composer dump-autoload). Perhaps I'm doing something wrong, or there is a proper way and this is not it.

2) It seems everytime I pull my app down from Git I'll have to re-configure the config files and metadata within the library files (which aren't version controlled). Is this the only way?

Anyway I'm kinda new to SimpleSAMLphp so just trying to figure how best to integrate it into my apps. By the way, my apps are build in Zend framework 1 if that helps any. Would appreciate any help, thanks.

cpliakas commented 9 years ago

Hi @martynbiz.

The honest answer to question 1. is that I am not sure. There is a related issue posted at #2, but the challenge I see is that SimpleSAMLphp has it's own autoload mechanism which may or may not conflict with Composer's. The original goal of this project was to use Composer to simplify downloading and updating SimpleSAMLphp, but since Composer isn't a first-class citizen there are workarounds that have to be applied to make it work as expected in your app. With that being said, as an alternative to replicating SimpleSAMLphp's autoloader in Composer you could also source the _autoload.php file via Composer's files field so you can reuse the existing system without having to explicitly source the autoloader in your app.

Regarding 2., I don't have a great answer for this either. You could fork the project and either include your configs in it or require a file in your app outside of SimpleSAMLphp that can be committed to your VCS. I also experimented with using scripts to automatically generate the configs based on my apps requirements. It worked but seems heavy.

Anyways, sorry for not having better answers to these questions. I'd love for people to share their solutions, hacks, and workarounds so that we can identify on best practices. Maybe the upstream repo can learn from the techniques discussed here and can incorporate Composer-based workflows into the core codebase.

Thanks for posting, Chris

martynbiz commented 9 years ago

No problem, just wanted some opinions. If I come across a good way to handle these I'll post back. Thanks for your thoughts.

ghost commented 7 years ago

Hi @cpliakas, I am using simple samlPhp in my application, i want to know how to use it without using composer with ZF1 framework.

cpliakas commented 7 years ago

Hi @sandipmangale. The scope of this project is to bridge SimplaSAMLphp with Composer, so general questions about the SimplaSAMLphp application would be better addressed in that project's help channels. I'd suggest posting this question to an issue at https://github.com/simplesamlphp/simplesamlphp in order to get the guidance you need. Hope this points you in the right direction.

Thanks for posting! Chris