2017 © Pedro Peláez
 

library atom-feed

A simple atom feed builder for PHP

image

ancoka/atom-feed

A simple atom feed builder for PHP

  • Saturday, June 2, 2018
  • by ancoka
  • Repository
  • 1 Watchers
  • 2 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

atom-feed

atom-feed是一个采用Atom协议的用于生成网站聚合应用信息的一个简单的PHP程序。, (*1)

安装

环境要求:PHP >= 5.4 直接使用composer命令安装:, (*2)

composer require "ancoka/atom-feed:~1.0"

或者添加如下代码到composer.json文件中:, (*3)

{
    "require": {
        "ancoka/atom-feed" : "~1.0"
    }
}

然后运行composer来安装它, (*4)

composer install

使用前引入 "vendor/autoload.php" 文件:, (*5)

require_once 'vendor/autoload.php';

使用

<?php
require_once dirname(__DIR__)."/vendor/autoload.php";

use Ancoka\XMLBuilder\Atom;
use Ancoka\XMLBuilder\Feed;
use Ancoka\XMLBuilder\Entry;

$atom = new Atom();

$feed = new Feed();
$feed->title('title')
     ->subtitle('subtitle')
     ->id('http://www.example.com')
     ->updated(time())
     ->link(['href' => 'http://www.example.com'])
     ->link(['href' => 'http://www.example.com/atom.xml', 'rel' => 'self'])
     ->rights('© 2005 Example, Inc.')
     ->appendTo($atom);


$entry = new Entry();
$entry->id('http://www.example.com/article/1')
      ->title('article title 1')
      ->subtitle('article subtitle 1')
      ->summary('article summary 1')
      ->content('article content 1')
      ->category(['term' => 'category1', 'scheme' => 'http://www.ucoolife.com/category/category1'])
      ->author(['name' => 'kevin', 'email' => 'example@gmail.com', 'uri' => 'http://example.com/~kevin'])
      ->appendTo($feed);

$entry = new Entry();
$entry->id('http://www.example.com/article/2')
      ->title('article title 2')
      ->subtitle('article subtitle 2')
      ->summary('article summary 2')
      ->content('article content 2')
      ->category(['term' => 'category2', 'scheme' => 'http://www.ucoolife.com/category/category2'])
      ->author(['name' => 'kevin', 'email' => 'example@gmail.com', 'uri' => 'http://example.com/~kevin'])
      ->appendTo($feed);

header('Content-type:application/atom+xml; charset=utf-8');
echo $atom;

上面代码涵盖常用用法,更多请查看接口文件源码:AtomInterfaceFeedInterfaceEntryInterface, (*6)

参考

License

MIT, (*7)

The Versions

02/06 2018

dev-master

9999999-dev

A simple atom feed builder for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Avatar ancoka

atom feed rss builder

12/01 2018

dev-develop

dev-develop

A simple atom feed builder for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Avatar ancoka

atom feed rss builder

09/02 2017

1.0.1

1.0.1.0

A simple atom feed builder for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by Avatar ancoka

atom feed rss builder

30/04 2016

1.0

1.0.0.0

A simple atom feed builder for PHP

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

by 江小溅

atom feed rss builder