artesaos / seotools

SEO Tools for Laravel
MIT License
3.12k stars 503 forks source link

Agnostic Package #5

Open vinicius73 opened 9 years ago

vinicius73 commented 9 years ago

Transforming the package in a package that does not depend on Laravel.


Transformar o pacote em um pacote que não dependa do Laravel.

rombat commented 9 years ago

That would be great! I'd like to use this package for Laravel 4.2 actually.

vinicius73 commented 9 years ago

@rombat you can use https://github.com/vinicius73/SeoTools

edbizarro commented 8 years ago

Quando finalizarmos os testes vou pra essa :D

jakemitchellxyz commented 8 years ago

All you would have to do is remove all of the laravel helper functions (like array_forget() and array_get()) -- or better yet, include those functions in your own helpers.php file and include them via composer.json like:

"files": [
    "src/resources/helpers.php"
]

but once all of the helper functions are taken care of, the package is already agnostic. Someone not using Laravel could simply not register the service provider or alias, and use:

<?php
use Artesaos\SEOTools\SEOTools as SEO;

class SomeClass
{
    public function generateView()
    {
        SEO::setTitle('Home')->setDescription('Welcome to my website!');
        echo SEO::generate();
    }
}

obviously, that's an odd example, but it shows that a user can already use the package without Laravel. This is because the only thing Laravel is used for is setting up the Aliases and config (I am remove the config in my next pull, so if that is accepted, you won't have to worry about the config)

jakemitchellxyz commented 8 years ago

^^ As a matter of fact, someone using Laravel can even use the package without the Service Provider (once the config is gone)