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

Use Composer to manage all 3rd-party PHP libraries #613

Closed
3 tasks done
virtualtam opened this issue Jul 28, 2016 · 15 comments
Closed
3 tasks done

Use Composer to manage all 3rd-party PHP libraries #613

virtualtam opened this issue Jul 28, 2016 · 15 comments
Assignees
Labels
3rd party interoperability with third-party platforms documentation enhancement tools developer tools
Milestone

Comments

@virtualtam
Copy link
Member

virtualtam commented Jul 28, 2016

3rd-party libs shouldn't be part of Shaarli's codebase, but managed and pinned using Composer, and referenced by autoloading (see #607, #608, #612):

@virtualtam virtualtam added enhancement easy good place to start contributing tools developer tools 3rd party interoperability with third-party platforms labels Jul 28, 2016
@virtualtam virtualtam added this to the 0.8.1 milestone Jul 28, 2016
@virtualtam virtualtam self-assigned this Jul 28, 2016
@ArthurHoaro
Copy link
Member

We need to make sure that we're compatible with RainTPL 3.

@virtualtam
Copy link
Member Author

virtualtam commented Aug 16, 2016

@Marsup wrote:

A quick question as I'm no php expert : would it be feasible or desirable to commit the result of composer into git ? Does composer download system-specific binaries ? From what I read it downloads everything into a vendor folder, if there's no roadblock you could commit that and still keep all the advantages you mentioned.

A quick question, but for sure a tricky one! I've kept rewriting this post over and over for the last hour-or-so, as there are actually very few resources on the Web that address the matter in a structured, argumented way.

So instead of directly answering it, I'll give some pointers to interesting articles and posts I've stumbled upon while digging into the topic :)

@Marsup
Copy link

Marsup commented Aug 17, 2016

Having read all of that, you could still auto-update the dependencies with a git commit hook, also running the test suite to make sure everything's OK. There remains the problem of licensing, but you're probably not using such library.

@nodiscc
Copy link
Member

nodiscc commented Aug 17, 2016

Hi @alexisju you can still install shaarli on shared hosting; but not from git master. You will have to download a prebuilt ZIP at https://github.com/shaarli/Shaarli/releases (it's not there yet). THere will be 2 ways to install:

  1. From git (using git clone, or a zipball like https://github.com/shaarli/Shaarli/archive/master.zip). You will get Shaarli's source code without any dependencies, and will have to run composer to fetch them.
  2. From a prebuilt release ZIP. This ZIP file will be built by the maintainers (all dependencies fetched using composer) and uploaded to Github. This is the way to go for shared hosting.

@nodiscc
Copy link
Member

nodiscc commented Aug 17, 2016

@Marsup for what it's worth I don't see the point of pulling the 3rd party libs and commiting them to the repo, now that we have proper dependency management. It would make the git repository larger, etc. As I said above, if you don't want to run composer, use a prebuilt ZIP release (not released yet). If you download Shaarli from git you will have to run composer.

@Marsup
Copy link

Marsup commented Aug 17, 2016

I'll go with composer then. For me it's a much smoother upgrade process to let git manage the file deletion and renames. Using the zip means a much more manual and complex upgrade process.

@nodiscc
Copy link
Member

nodiscc commented Aug 17, 2016

I also use git to upgrade and manage versions and find it smoother than manual operations with ZIP files. Fortunately working with ZIPs can also be automated, and I intend to do that on my own setup soon. I currently use this ansible task to deploy Shaarli, I will do the required changes and post them here if anyone is interested. (basically it will backup the data/ directory, remove the whole shaarli install, download and extract the most recent zip, and restore data/).

There are some disadvantages with the new composer requirement (no more updates via git as @alexisju summarized here - unless you also have composer). I used to oppose this change when Shaarli was a total mess since git was convenient, but IMHO the advantages of having a cleaner codebase (thanks to the fantastic work of @virtualtam and @ArthurHoaro) outweighs this. After all Shaarli used to only be downloadable via ZIP archive on sebsauvage's site.

Let me know if you'd like something to be documented more.

@Marsup
Copy link

Marsup commented Aug 17, 2016

What are the advised options for a production server ? --no-dev ?

@nodiscc
Copy link
Member

nodiscc commented Aug 17, 2016

I believe yes composer update --no-dev.

@virtualtam can you update

with the latest changes regarding the installation procedure? I still think these pages should be condensed in a single one, and the server config examples moved to separate linked pages.

It would be nice to have a Makefile target for installation so that users don't need to figure out composer commands.

@virtualtam
Copy link
Member Author

virtualtam commented Aug 17, 2016

@nodiscc I've already updated instructions related to the master branch along #607. Instructions for production / stable branch will be updated once a new version is released

@nodiscc
Copy link
Member

nodiscc commented Aug 17, 2016

@virtualtam Ok I just merged the download and installation pages in the wiki, and updated the README to point to the correct page.

https://github.com/shaarli/Shaarli/wiki/Download-and-Installation

@virtualtam
Copy link
Member Author

Thanks @nodiscc ;-)

@virtualtam
Copy link
Member Author

virtualtam commented Oct 16, 2016

I'm currently working on bumping RainTPL from 2.7 to 3.1, as it's only available from Composer/Packagist starting with 3.0 - https://packagist.org/packages/rain/raintpl

In doing so, I stumbled upon what seems to be an inconsistency in the current templates:

~/dev/shaarli $ ag 'loop=' tpl

tpl/linklist.paging.html
15:    {loop="$action_plugin"}

tpl/tagcloud.html
8:        {loop="$plugin_start_zone"}
14:        {loop="tags"}
17:            {loop="$value.tag_plugin"}
24:        {loop="$plugin_end_zone"}

tpl/page.header.html
37:    {loop="$plugins_header.buttons_toolbar"}
46:        {loop="plugin_errors"}

There are two syntaxes used when looping:

  • sometimes over a variable: {loop="$plugin_start_zone"}
  • sometimes over a variable name: {loop="plugin_errors"}

Though RainTPL 2.7 doesn't seem to be too picky about it, this leads to RainTPL 3.1 generating erroneous PHP code from templates.

@nodiscc @ArthurHoaro @alexisju @kalvn, did you notice similar issues while working on templates?

I'll do further tests to see if it's possible to get templates that work with both RainTPL versions before actually upgrading to 3.1.

virtualtam added a commit to virtualtam/Shaarli that referenced this issue Oct 16, 2016
Relates to shaarli#613

Before: {loop="someVariable"}
After:  {loop="$someVariable"}

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
@ArthurHoaro
Copy link
Member

It's quite funny, I noticed the same thing today while working on templates. I switched to {loop="$var"} for consistency. Which one is supported by RainTPL 3?

@virtualtam
Copy link
Member Author

{loop="$var"} works fine with both RainTPL versions, #660 submitted to cleanup loop declaration :)

@virtualtam virtualtam removed the easy good place to start contributing label Oct 17, 2016
virtualtam added a commit to virtualtam/Shaarli that referenced this issue Oct 19, 2016
Relates to shaarli#613

Modifications:
- update Rain\Tpl initialization code:
  - autoload with Composer
  - update configuration
  - set 'auto_escape' to false
- [template] reference static resources relatively to the index page,
             not to the template file anymore,
             e.g. '../inc/script.js' becomes 'inc/script.js'
- [template] linklist: move "link updated date" processing to PHP code

RainTPL 3.1 specificities:
- no complex variable processing in templates:
    - `{$var1=$var2}` works
    - `{$var1=$condition ? 'Value1' : 'Value2'}` does not

WIP:
- check PHP compatibility
- check all pages work properly

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
virtualtam added a commit to virtualtam/Shaarli that referenced this issue Oct 19, 2016
Relates to shaarli#613

Modifications:
- update `Rain\Tpl` initialization code:
  - autoload with Composer
  - update configuration
  - set 'auto_escape' to false
- [template] reference static resources relatively to the index page
- [template] linklist: move "link updated date" processing to PHP code

RainTPL 3.1 specificities:
- no complex variable processing in templates:
    - `{$var1=$var2}` works
    - `{$var1=$condition ? 'Value1' : 'Value2'}` does not
- static resources are now referenced relatively to the index page,
  not to the template file, e.g. '../inc/script.js' becomes 'inc/script.js'

WIP:
- check PHP compatibility
- check all pages work properly

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
@virtualtam virtualtam modified the milestones: 0.9.0, 0.8.1 Oct 20, 2016
ArthurHoaro added a commit to ArthurHoaro/Shaarli that referenced this issue Oct 22, 2016
ArthurHoaro pushed a commit that referenced this issue Nov 5, 2016
Relates to #613

Before: {loop="someVariable"}
After:  {loop="$someVariable"}

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
ArthurHoaro added a commit that referenced this issue Nov 5, 2016
virtualtam added a commit to virtualtam/Shaarli that referenced this issue Dec 22, 2016
Relates to shaarli#613

Modifications:
- update `Rain\Tpl` initialization code:
  - autoload with Composer
  - update configuration
  - set 'auto_escape' to false
- [template] reference static resources relatively to the index page
- [template] linklist: move "link updated date" processing to PHP code

RainTPL 3.1 specificities:
- no complex variable processing in templates:
    - `{$var1=$var2}` works
    - `{$var1=$condition ? 'Value1' : 'Value2'}` does not
- static resources are now referenced relatively to the index page,
  not to the template file, e.g. '../inc/script.js' becomes 'inc/script.js'

WIP:
- check PHP compatibility
- check all pages work properly

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
virtualtam added a commit to virtualtam/Shaarli that referenced this issue Jan 7, 2017
Relates to shaarli#613

Modifications:
- update `Rain\Tpl` initialization code:
  - autoload with Composer
  - update configuration
  - set 'auto_escape' to false
- [template] reference static resources relatively to the index page
- [template] linklist: move "link updated date" processing to PHP code

RainTPL 3.1 specificities:
- no complex variable processing in templates:
    - `{$var1=$var2}` works
    - `{$var1=$condition ? 'Value1' : 'Value2'}` does not
- static resources are now referenced relatively to the index page,
  not to the template file, e.g. '../inc/script.js' becomes 'inc/script.js'

WIP:
- check PHP compatibility
- check all pages work properly

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
virtualtam added a commit to virtualtam/Shaarli that referenced this issue Jan 7, 2017
Relates to shaarli#613

Modifications:
- update `Rain\Tpl` initialization code:
  - autoload with Composer
  - update configuration
  - set 'auto_escape' to false
- [template] reference static resources relatively to the index page
- [template] linklist: move "link updated date" processing to PHP code

RainTPL 3.1 specificities:
- no complex variable processing in templates:
    - `{$var1=$var2}` works
    - `{$var1=$condition ? 'Value1' : 'Value2'}` does not
- static resources are now referenced relatively to the index page,
  not to the template file, e.g. '../inc/script.js' becomes 'inc/script.js'

WIP:
- check PHP compatibility
- check all pages work properly

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
portailp pushed a commit to PortailPro/Shaarli that referenced this issue Mar 20, 2017
Relates to shaarli#613

Before: {loop="someVariable"}
After:  {loop="$someVariable"}

Signed-off-by: VirtualTam <virtualtam@flibidi.net>
portailp pushed a commit to PortailPro/Shaarli that referenced this issue Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party interoperability with third-party platforms documentation enhancement tools developer tools
Projects
None yet
Development

No branches or pull requests

4 participants