Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The idea is as to install Vendor.Package to package if aura-package <pac... #24

Closed
wants to merge 1 commit into from
Closed

Conversation

harikt
Copy link
Contributor

@harikt harikt commented Jul 31, 2012

...kage-name> provided and download and install 3rd party packages to include folder when aura-include is provided

I feel this will not work :P .

The idea is to keep a composer.json in https://github.com/auraphp/system

{
    "name": "auraphp/package",
    "type": "aura-package",
    "require": {
        "composer/installers": "*"
    }
}

I am also wondering if we are adding to other packages which can be used independently will that also download in package folder ?

Which should go to the normal vendor directory of the user choosen .

"require": {
    "composer/installers": "*"
}

https://github.com/auraphp/Aura.Framework/blob/master/composer.json#L33

…package-name> provided and download and install 3rd party packages to include folder when aura-include is provided
@harikt
Copy link
Contributor Author

harikt commented Jul 31, 2012

I am interested to discuss about this .

The base idea is as of the topic

https://groups.google.com/forum/?fromgroups#!topic/composer-dev/GogrK7F6uLc

Which helps to install all the packages for the framework which is system

https://github.com/auraphp/system

Which contains a package folder .

@shama
Copy link
Contributor

shama commented Jul 31, 2012

Your pull request is correct.

Only packages with the type aura-package will be installed to package/{$name}/. If the type is the default, library then the package will be installed to the default composer location vendor.

Let me know if that makes sense and I'll merge this in. Thanks @harikt!

@harikt
Copy link
Contributor Author

harikt commented Jul 31, 2012

@shama hm .
This is ok , but I need some more help for the ones that I am really looking for .

For eg lets consider composer.json of Aura.Router : https://github.com/auraphp/Aura.Router/blob/master/composer.json

{
    "name": "aura/router",
    "type": "library",
    "description": "The Aura Router package implements web routing; given a URI path and a copy of $_SERVER, it will extract controller, action, and parameter values for a specific route.",
    "keywords": [
        "route",
    ],
    "homepage": "http://auraphp.github.com/Aura.Router",
    "version": "1.0.0-beta3",
    "time": "2012-07-30",
    "license": "BSD",
    "authors": [
    ],
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.4.0"
    },
    "minimum-stability": "dev",
    "autoload": {
        "psr-0": {
            "Aura\\Router": "src/"
        }
    }
}

The Aura.Router is exactly a library which can be used independently .

But when its used inside the system folder I need it to download it at package folder . Not just Aura.Router , but also for some more packages which are Aura specific . Is there a way we can work on for composer ?

├── config
│   ├── default.php
│   ├── dev.php
│   ├── local.php
│   ├── prod.php
│   ├── staging.php
│   └── test.php
├── include
│   ├── doctrine
│   └── zf2
│       └── library
├── LICENSE
├── package
│   ├── Aura.Router
│   │   └── src
│   └── Aura.Web
│       └── src
├── README.md
├── status.php
├── tmp
├── update.php
└── web
    ├── cache
    ├── favicon.ico
    └── index.php

So how can I make it happen that way ?

Thank you .

@shama
Copy link
Contributor

shama commented Jul 31, 2012

Yes, if this is merged you would just set the type of Aura.Router to aura-package and require composer/installers. Then when the package is installed it will be placed into the package folder.

The only part I am unsure of is the autoloading. Installing packages to a folder other than vendor assumes the framework has implemented their own autoloading mechanism.

If Aura is or can use the vendor folder for packages and the Composer autoloader, then I would recommend using that instead. composer/installers is only for bending composer to another framework's existing conventions. The hope is one day all frameworks would use a single package install path and there would only be 1 package type: library.

@harikt
Copy link
Contributor Author

harikt commented Jul 31, 2012

@shama in that case what will happen if I need to download Aura.Router as a library?

I agreed that when the type is changed to aura-package it will install it in package folder.

But here there are two options I need . Probably you didn't get it completely .

Aura.Router can be used standalone or if I am using aura as a framework , I need to download it in package folder. In that case Aura.Autoload will do the work of autoloading .

But if its installed just as a library I need composer to autoload it .

@shama
Copy link
Contributor

shama commented Jul 31, 2012

Ah I see. Thanks for clarifying. Then you would need to use the extra.installer-paths in only the framework composer.json, like this:

{
    "require": {
        "composer/installers": "*"
    },
    "extra": {
        "installer-paths": {
            "package/Aura.Router/": ["aura/router"],
            "package/Aura.Web/": ["aura/web"],
        }
    }
}

That would also mean the types in this PR wouldn't be necessary.

@shama shama mentioned this pull request Jul 31, 2012
@harikt
Copy link
Contributor Author

harikt commented Jul 31, 2012

@shama Thank you for clarifying . I will ask @pmjones to check with this .

@harikt
Copy link
Contributor Author

harikt commented Jul 31, 2012

@shama one more thing I feel seems good, if its merged we can make use of other Aura packages like Hari.Contact etc . So I can just issue

composer install aura-package hari/blog 

something like that .

@shama
Copy link
Contributor

shama commented Jul 31, 2012

That won't work. AFAIK, composer only works off the composer.json.

If you added a composer.json to Hari.Contact and installed by adding "require": { "harikt/contact": "*" } to your app's composer.json (assuming that is the vendor/name in packagist.org). Then ran composer.phar install it would install to the vendor folder of your app.

One use of composer/installers that might benefit Aura is the package name inflection. Do all Aura packages follow the convention Vendor.Name? eg Hari.Contact, Hari.Blog, Shama.MyAuraPackage, etc.

We could add the type aura-library that would install to vendor/{$vendor}.{$name}/ and capitalize the first letters of Vendor and Name.

@pmjones
Copy link

pmjones commented Jul 31, 2012

Do all Aura packages follow the convention Vendor.Name? eg Hari.Contact, Hari.Blog, Shama.MyAuraPackage, etc.

Yes. The naming convention is PSR-0 related.

Regarding the dot separator:

PSR-0 allows for underscores in the namespace portion, where those underscores are not converted to directory separators. (Underscores in the classname portion are converted to directory separators.) This means that we can't use an underscore as a separator between the vendor name and the package name; one would not be able to tell where the vendor name ended and the package name began. Likewise, slashes, colons, and backslashes won't work because they are already directory separators in different filesystems (and for other reasons). Thus, we use the dot as the separator, to delineate between the vendor name and the package name.

Regarding casing:

We use the same case in the package names as the namespace; so, Aura.Uri is a package using the namespace Aura\Uri. That means less converting back-and-forth between expected package names and expected namespaces.

@harikt
Copy link
Contributor Author

harikt commented Jul 31, 2012

@shama what I was thinking was if I have a composer.json in Hari.Blog

{
    "name": "hari/blog",
    "type": "aura-package",
    "require": {
        "composer/installers": "*"
    }
}

and later I add hari/blog as required in the system composer.json as in with the help you have given

https://github.com/harikt/aura-system/blob/master/composer.json

will it download automatically without me specifying the extra.installer-paths ?

So the base idea is I just can add the required onces other than Aura.Packages and the remaining all other Vendor packages which are dependent on aura can be added in a single line.

Qn : Do all Aura packages follow the convention Vendor.Name? eg Hari.Contact, Hari.Blog, Shama.MyAuraPackage, etc.

Ans : Yes all Aura packages follow Vendor.Package format and resides in package folder inside the system .

Qn : We could add the type aura-library that would install to vendor/{$vendor}.{$name}/ and capitalize the first letters of Vendor and Name.

I feel package name itself is good , can we make that download to package folder ?
So it can download to package/{$vendor}.{$name}/

I have created the system and is at http://packagist.org/packages/hari/aura-system

So once I download system from https://github.com/harikt/aura-system and run composer.phar install I feel it will download all files to package/Aura.Package .

I want to test, but as I am running on RC 5.4 , I am not able to do :) .

Thank you .

@shama
Copy link
Contributor

shama commented Jul 31, 2012

@harikt What you have in hari/aura-system looks correct.

We can implement aura-package to install to the package/($vendor}.{$name}/ folder. It's entirely up to you guys on what you expect from your package authors. I suggested aura-library because I thought from our earlier conversation, non-core Aura packages used the Composer default vendor folder (and the default Composer type is library).

If the convention for Aura is all packages should go into the package folder and Aura has it's own autoloading mechanism to handle this (which it sounds like it is the case)... then we should add the aura-package and aura-include types to composer/installers. Along with a name inflection to Vendor.Name for packages only.

Sound good? We could change this after some trial as well. Only types marked in bold in the README are guaranteed to not change.

@harikt
Copy link
Contributor Author

harikt commented Aug 1, 2012

Hi @shama

Thank you for your quick reply . I will discuss with folks and say . Lets wait for a while .

@harikt
Copy link
Contributor Author

harikt commented Aug 1, 2012

Hey @shama

I did tried as you mentioned . But it seems its not downloading to package folder as mentioned. I am not sure whether this is the real behaviour or not . See the composer.json , after running install and later the ls output .

hari@vostro-lx1:/var/www/composer$ cat composer.json
{
    "name": "hari/aura-system",
    "minimum-stability": "dev",
    "require": {
        "composer/installers": "*",
        "aura/autoload": "1.0.0-beta3",
        "aura/cli": "1.0.0-beta3",
        "aura/di": "1.0.0-beta3",
        "aura/http": "1.0.0-beta3",
        "aura/marshal": "1.0.0-beta3",
        "aura/router": "1.0.0-beta3",
        "aura/signal": "1.0.0-beta3",
        "aura/sql": "1.0.0-beta3",
        "aura/uri": "1.0.0-beta3",
        "aura/view": "1.0.0-beta3",
        "aura/web": "1.0.0-beta3"
    },
    "extra": {
        "installer-paths": {
            "package/Aura.Autoload/": ["aura/autoload"],
            "package/Aura.Cli/": ["aura/cli"],
            "package/Aura.Di/": ["aura/di"],
            "package/Aura.Http/": ["aura/http"],
            "package/Aura.Marshal/": ["aura/marshal"],
            "package/Aura.Router/": ["aura/router"],
            "package/Aura.Signal/": ["aura/signal"],
            "package/Aura.Sql/": ["aura/sql"],
            "package/Aura.Uri/": ["aura/uri"],
            "package/Aura.View/": ["aura/view"],
            "package/Aura.Web/": ["aura/web"]
        }
    }
}
hari@vostro-lx1:/var/www/composer$ php composer.phar install
Installing dependencies
  - Installing composer/installers (dev-master)
    Cloning c515efe6e807b09b51eba0f5f6188868156edd8b

  - Installing aura/autoload (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/cli (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/di (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/http (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/marshal (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/router (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/signal (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/sql (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/uri (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/view (1.0.0-beta3)
    Downloading: 100%         

  - Installing aura/web (1.0.0-beta3)
    Downloading: 100%         

Writing lock file
Generating autoload files


ls package/
hari@vostro-lx1:/var/www/composer$ ls vendor/
aura  Aura  autoload.php  composer
hari@vostro-lx1:/var/www/composer$ ls vendor/aura/
uri
hari@vostro-lx1:/var/www/composer$ ls vendor/Aura/
Autoload  Cli  Di  Http  Marshal  Router  Signal  Sql  View  Web

@harikt
Copy link
Contributor Author

harikt commented Aug 1, 2012

@pmjones I feel we should stick on to composer-installer so that the packages will not be downloaded else where like two folders as of now ( aura and Aura ) and also as you mentioned earlier when we download from github repo the name of the package will be Aura.Package .

So the goal what we thought and named the package will break which I am not really interested . We will rename the include folder to vendor so that any 3rd party libraries will be downloaded to vendor folder .

And all the @auraphp and Vendor.Package of aura related ones will be to package folder via the extra.installer-paths as mentioned by @shama .

Thoughts on this ?

@shama
Copy link
Contributor

shama commented Aug 1, 2012

@harikt What you did should work. I'll give it a shot later and get back to you.

@harikt
Copy link
Contributor Author

harikt commented Aug 1, 2012

ok I will wait . But this didn't happened for me .

@harikt
Copy link
Contributor Author

harikt commented Aug 2, 2012

@shama any progress ?

@henrikbjorn
Copy link

Seems like you are doing a lot of stuff to bend around how composer should work. Is there any reason for alle the libraries to not be in vendor ? And use target-path to force your Aura.Package scheme?

@harikt
Copy link
Contributor Author

harikt commented Aug 2, 2012

@henrikbjorn yes this post is a good reference what exactly the framework is doing https://groups.google.com/d/topic/auraphp/QhIQVLd3S3g/discussion

@shama
Copy link
Contributor

shama commented Aug 2, 2012

@harikt Okay figured out the problem. Two things:

  1. Each of those Aura packages don't require composer/installers in their composer.json. So they are not using composer/installers. Which is why it's installing to the default Composer location. They each need to have "require": { "composer/installers": "*" } in them.
  2. Since an Aura type currently doesn't exist in composer/installers each of those packages would be ignored even if they require composer/installers. Because installers ignores any type not implemented, it never checks for the extra.installer-paths config (I guess I never considered anyone trying to use it on a type not implemented :).

The following example composer.json example will override the package and use the cakephp-plugin type to bypass the type check. Please use it to test:

{
    "name": "hari/aura-system",
    "minimum-stability": "dev",
    "repositories": {
        "aura-unofficial": {
            "type": "package",
            "package": {
                "type": "cakephp-plugin",
                "name": "aura/autoload",
                "version": "1.0.0-beta3",
                "source": {
                    "url": "git://github.com/auraphp/Aura.Autoload.git",
                    "type": "git",
                    "reference": "origin/master"
                },
                "require": {
                    "composer/installers": "*"
                }
            }
        }
    },
    "require": {
        "composer/installers": "*",
        "aura/autoload": "1.0.0-beta3"
    },
    "extra": {
        "installer-paths": {
            "package/Aura.Autoload/": ["aura/autoload"]
        }
    }
}

What we should do from here is:

  1. Implement a Aura installer type (merge this PR).
  2. Edit each composer.json of those Aura packages to have "require": { "composer/installers": "*" } and "type": "aura-package".

Then you can install without needing the extra.installer-paths. Let me know if you have any questions. Cheers!

@shama
Copy link
Contributor

shama commented Aug 2, 2012

Aura types: aura-package and aura-include implemented: c515efe...305f3ce

You can change the cakephp-plugin to aura-package in the above example for testing. This PR has been merge but leaving it open until your done with testing. Just let me know if those types are good and solid and I'll mark them as stable (never going to change).

Thanks!

@harikt
Copy link
Contributor Author

harikt commented Aug 3, 2012

Thank you for the help.

A few questions :

1 ) Each of those Aura packages don't require composer/installers in their composer.json. So they are not using composer/installers. Which is why it's installing to the default Composer location. They each need to have "require": { "composer/installers": "*" } in them.

If we add "composer/installers" in those Aura packages, does that mean composer will not be able to autoload a single package .

As I said if I am going to use Aura.Router only , currently composer can autoload . What I understand is if we add the aura-package composer will fails to autoload .

2 ) Since an Aura type currently doesn't exist in composer/installers each of those packages would be ignored even if they require composer/installers. Because installers ignores any type not implemented, it never checks for the extra.installer-paths config (I guess I never considered anyone trying to use it on a type not implemented :).

What I did was added a AuraInstaller in vendor/composer/installers/src/Composer/Installers/ and tried :) . I am not sure that really helps . But it didn't worked. Probably the reason may be we don't have named in the other composer.json of the Aura packages.

Yes your example works. The composer.json of mine is

{
    "name": "hari/aura-system",
    "minimum-stability": "dev",
    "repositories": {
        "aura-unofficial": {
            "type": "package",
            "package": [{
                "type": "aura-package",
                "name": "aura/autoload",
                "version": "1.0.0-beta3",
                "source": {
                    "url": "git://github.com/auraphp/Aura.Autoload.git",
                    "type": "git",
                    "reference": "origin/master"
                },
                "require": {
                    "composer/installers": "*"
                }
            },
            {
                "type": "aura-package",
                "name": "aura/cli",
                "version": "1.0.0-beta3",
                "source": {
                    "url": "git://github.com/auraphp/Aura.Cli.git",
                    "type": "git",
                    "reference": "origin/master"
                },
                "require": {
                    "composer/installers": "*"
                }
            }
            ]
        }
    },
    "require": {
        "composer/installers": "*",
        "aura/autoload": "1.0.0-beta3",
        "aura/cli": "1.0.0-beta3",
        "aura/di": "1.0.0-beta3",
        "aura/http": "1.0.0-beta3",
        "aura/marshal": "1.0.0-beta3",
        "aura/router": "1.0.0-beta3",
        "aura/signal": "1.0.0-beta3",
        "aura/sql": "1.0.0-beta3",
        "aura/uri": "1.0.0-beta3",
        "aura/view": "1.0.0-beta3",
        "aura/web": "1.0.0-beta3"
    },
    "extra": {
        "installer-paths": {
            "package/Aura.Autoload/": ["aura/autoload"],
            "package/Aura.Cli/": ["aura/cli"],
            "package/Aura.Di/": ["aura/di"],
            "package/Aura.Http/": ["aura/http"],
            "package/Aura.Marshal/": ["aura/marshal"],
            "package/Aura.Router/": ["aura/router"],
            "package/Aura.Signal/": ["aura/signal"],
            "package/Aura.Sql/": ["aura/sql"],
            "package/Aura.Uri/": ["aura/uri"],
            "package/Aura.View/": ["aura/view"],
            "package/Aura.Web/": ["aura/web"]
        }
    }
}

Some doubts is

3 ) currently for aura/autoload and aura/cli we have placed

"source": {
    "url": "git://github.com/auraphp/Aura.Autoload.git",
        "type": "git",
            "reference": "origin/master"
    },

I am not really familiar the internal working . Does that means composer is downloading package via git and the user needs git to download ?

4 ) For each package aura/autoload , aura/cli etc though we have a composer.json and as its not having the wordings "require": { "composer/installers": "*" } we are forced to write again a few lines.

Is there a way that composer knows when we can get rid of this via composer itself understanding checking extra.installer-paths ? So we don't need to write the whole long composering ( like things written in aura-unofficial ) the packages like we don't have composer.json in that package ? ( This has relation with Qn 1 )

Else what I am seeing is we need to go and edit the version at two places , and in future this may become tedious :) . One at the require itself and the other at the aura-unofficial itself.

for the time please keep this open . @pmjones is trying to make it work the way composer is working. That means it will download all aura packages in vendor folder as default composer is doing . I am not sure how much fruitful it is for we have a blocker in packagist composer/packagist#186 .

And I am not satisfied with the current composer.json ( of mine ) for we need to add more lines as in aura-unofficial as we already have a composer.json but for we have'nt kept the composer installer for its really a library , and can be autoloaded individually .

Thank you once again for your hard work on this. I appreciate.

@harikt
Copy link
Contributor Author

harikt commented Aug 3, 2012

So the horrible composer.json for aura may look like https://gist.github.com/3243564

@shama
Copy link
Contributor

shama commented Aug 3, 2012

You wouldn't want to use the aura-unofficial repo lines in your composer.json for anything beyond testing.

I may still be confused but I think the issue is this:
A) You want to use Composer to build the system from a collection of packages.
B) You want users to use the default vendor folder and Composer autoload for packages outside the system.

If that is the case then I think you shouldn't use Composer to build the system framework. I think git submodules would be a better choice for that. Or build your own Aura Composer Installer that handles that use case.

@shama
Copy link
Contributor

shama commented Aug 3, 2012

I don't mind helping you to build an Aura Composer Installer either. They made it fairly easy to do. It would install each to the package folder if install from system but default to the vendor folder if installed elsewhere. Let me know and I'll setup a repo getting one started.

@harikt
Copy link
Contributor Author

harikt commented Aug 3, 2012

Yes you are correct.
We are looking
A) You want to use Composer to build the system from a collection of packages.
B) You want users to use the default vendor folder and Composer autoload for packages outside the system.
Yes @shama , please help with that ? I have been spending more time figuring what and how exactly should I go.

Thank you.

@harikt
Copy link
Contributor Author

harikt commented Aug 3, 2012

@shama one more thing is

Eg : Let say Hari.Package is aura related package , I will add in Hari.Package/composer.json the type as aura-package . so this PR still has relevance .

I also would like to hear @pmjones voice what he currently is thinking .

@harikt
Copy link
Contributor Author

harikt commented Aug 5, 2012

@shama did you got any progress ? Else I am interested to know how I can do or how I can achieve it .

@shama
Copy link
Contributor

shama commented Aug 5, 2012

@harikt Just published an installer for aura-system. If shama/aura-system-installer is required then packages will be installed to package/Vendor.Name/. So only aura-system should require this installer.

Please test and let me know if you have any questions. Let's move this conversation over to shama/aura-system-installer#1 as well. Cheers and closing.

@shama shama closed this Aug 5, 2012
@harikt
Copy link
Contributor Author

harikt commented Aug 5, 2012

A BIG Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants