-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d305086
Showing
19 changed files
with
941 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin | ||
docs/tests/coverage | ||
vendor | ||
.idea | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
build: | ||
environment: | ||
php: 7.3 | ||
|
||
coding_style: | ||
php: | ||
spaces: | ||
around_operators: | ||
concatenation: false | ||
other: | ||
after_type_cast: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
language: php | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
php: | ||
- 7.2 | ||
- 7.3 | ||
- 7.4 | ||
- nightly | ||
|
||
env: | ||
global: | ||
- LATEST_PHP_VERSION="7.4" | ||
matrix: | ||
- SYMFONY_VERSION="3.4.*" | ||
- SYMFONY_VERSION="4.3.*" | ||
- SYMFONY_VERSION="4.4.*" | ||
- SYMFONY_VERSION="5.0.*" | ||
- SYMFONY_VERSION="5.1.*" | ||
- SYMFONY_VERSION="dev-master" | ||
- DEPENDENCIES="beta" | ||
- DEPENDENCIES="low" | ||
- DEPENDENCIES="stable" | ||
|
||
matrix: | ||
fast_finish: true | ||
allow_failures: | ||
- php: nightly | ||
- env: DEPENDENCIES="beta" | ||
- env: DEPENDENCIES="low" | ||
- env: SYMFONY_VERSION="dev-master" | ||
|
||
before_install: | ||
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini | ||
- if [ -n "$GH_TOKEN" ]; then | ||
composer config github-oauth.github.com ${GH_TOKEN}; | ||
fi; | ||
- mkdir -p build/logs | ||
|
||
install: | ||
- if [ "$(phpenv version-name)" != "$LATEST_PHP_VERSION" ]; then | ||
composer remove friendsofphp/php-cs-fixer phpstan/phpstan phpstan/phpstan-phpunit --dev; | ||
fi | ||
- if [ "$DEPENDENCIES" = "beta" ]; then | ||
composer config minimum-stability beta; | ||
composer update -n --prefer-dist; | ||
elif [ "$DEPENDENCIES" = "low" ]; then | ||
composer update -n --prefer-dist --prefer-lowest; | ||
elif [ "$SYMFONY_VERSION" != "" ]; then | ||
composer remove symfony/symfony --dev && | ||
composer require symfony/symfony:"${SYMFONY_VERSION}" --dev --no-update; | ||
else | ||
composer update -n --prefer-dist; | ||
fi; | ||
|
||
script: | ||
- if [ "$(phpenv version-name)" != "$LATEST_PHP_VERSION" ]; then | ||
echo "Static analysis is skipped for older PHP versions"; | ||
else | ||
composer run-static-analysis; | ||
fi; | ||
- if [ "$(phpenv version-name)" != "$LATEST_PHP_VERSION" ]; then | ||
echo "Code style check is skipped for older PHP versions"; | ||
else | ||
composer check-code-style; | ||
fi; | ||
- if [ "$(phpenv version-name)" != "$LATEST_PHP_VERSION" ]; then | ||
echo "Security check is skipped for older PHP versions"; | ||
else | ||
composer check-security; | ||
fi; | ||
- if [ "$(phpenv version-name)" != "$LATEST_PHP_VERSION" ]; then | ||
echo "Tests with reporting in Clover format are skipped for older PHP versions"; | ||
composer run-tests; | ||
else | ||
composer run-tests-with-clover; | ||
fi; | ||
|
||
after_script: | ||
- if [ "$(phpenv version-name)" != "$LATEST_PHP_VERSION" ]; then | ||
echo "Coveralls report is skipped for older PHP versions"; | ||
else | ||
bin/php-coveralls -v; | ||
fi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Yan Rogozinsky | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
[![Latest Stable Version](https://poser.pugx.org/janwebdev/social-post-bundle/version)](https://packagist.org/packages/janwebdev/social-post-bundle) | ||
[![Total Downloads](https://poser.pugx.org/janwebdev/social-post-bundle/downloads)](https://packagist.org/packages/janwebdev/social-post-bundle) | ||
## What's this? | ||
This is a [Symfony](https://www.symfony.com) bundle written in [PHP 8.1](https://www.php.net/manual/en/migration81.php) that wraps [janwebdev/social-post](https://github.com/janwebdev/social-post) - an easy way for simultaneous publishing to Facebook and Twitter. It was cloned from [this repo](https://github.com/martin-georgiev/social-post-bundle) and refactored to support PHP 8.1+ and Symfony 6.4 LTS and upper. | ||
|
||
|
||
---- | ||
## How to install it? | ||
Recommended way is through [Composer](https://getcomposer.org/download/) | ||
|
||
composer require janwebdev/social-post-bundle | ||
|
||
|
||
---- | ||
## Integration with Symfony | ||
*Add social networks configuration* | ||
|
||
# Usually part of config.yml | ||
social_post: | ||
publish_on: [facebook, twitter] # List which Social networks you will be publishing to and configure your access to them as shown below | ||
providers: | ||
facebook: | ||
app_id: "YOUR-FACEBOOK-APP-ID" | ||
app_secret: "YOUR-FACEBOOK-APP-SECRET" | ||
default_access_token: "YOUR-FACEBOOK-NON-EXPIRING-PAGE-ACCESS-TOKEN" | ||
page_id: "YOUR-FACEBOOK-PAGE-ID" | ||
enable_beta_mode: true | ||
default_graph_version: "v2.8" # Optional, also supports "mcrypt" and "urandom". Default uses the latest graph version. | ||
persistent_data_handler: "memory" # Optional, also supports "session". Default is "memory". | ||
pseudo_random_string_generator: "openssl" # Optional, also supports "mcrypt" and "urandom". Default is "openssl". | ||
http_client_handler: "curl" # Optional, also supports "stream" and "guzzle". Default is "curl". | ||
twitter: | ||
consumer_key: "YOUR-TWITTER-APP-CONSUMER-KEY" | ||
consumer_secret: "YOUR-TWITTER-APP-CONSUMER-SECRET" | ||
access_token: "YOUR-TWITTER-ACCESS-TOKEN" | ||
access_token_secret: "YOUR-TWITTER-ACCESS-TOKEN-SECRET" | ||
|
||
*Register the bundle* | ||
|
||
# Usually your app/AppKernel.php | ||
<?php | ||
// ... | ||
class AppKernel extends Kernel | ||
{ | ||
public function registerBundles() | ||
{ | ||
$bundles = [ | ||
// ... | ||
new \Janwebdev\SocialPostBundle\SocialPostBundle(), | ||
]; | ||
return $bundles; | ||
} | ||
// ... | ||
} | ||
|
||
*Post a test message* | ||
|
||
# Some Symfony container aware class | ||
<?php | ||
//... | ||
$message = new \Janwebdev\SocialPost\Message('your test message'); | ||
$container->get('social_post')->publish($message); | ||
|
||
---- | ||
## Additional help | ||
|
||
Facebook doesn't support non-expiring user access tokens. Instead, you can obtain a permanent page access token. When using such tokens you can act and post as the page itself. More information about the page access tokens from the official [Facebook documentation](https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension#extendingpagetokens). Some Stackoverflow answers ([here](https://stackoverflow.com/a/21927690/3425372) and [here](https://stackoverflow.com/a/28418469/3425372)) also can of help. | ||
|
||
---- | ||
## License | ||
This package is licensed under the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
paths: | ||
- ./src | ||
- ./tests | ||
|
||
layers: | ||
- name: Bundle | ||
collectors: | ||
- type: className | ||
regex: \\Janwebdev\\SocialPostBundle\\.* | ||
- name: Tests | ||
collectors: | ||
- type: className | ||
regex: \\Tests\\Janwebdev\\SocialPostBundle\\.* | ||
|
||
ruleset: | ||
Bundle: ~ | ||
Tests: | ||
- Bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
$rootDirectory = __DIR__.'/../../'; | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in($rootDirectory.'/src') | ||
->in($rootDirectory.'/tests'); | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRules( | ||
[ | ||
'@PSR2' => true, | ||
'@PHP56Migration' => true, | ||
'@PHP70Migration' => true, | ||
'@PHP71Migration' => true, | ||
'@DoctrineAnnotation' => true, | ||
'@PhpCsFixer' => true, | ||
'align_multiline_comment' => false, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'backtick_to_shell_exec' => true, | ||
'blank_line_before_statement' => ['statements' => ['break', 'declare', 'continue', 'declare', 'die', 'do', 'exit', 'return', 'throw', 'try', 'while']], | ||
'cast_spaces' => ['space' => 'single'], | ||
'concat_space' => ['spacing' => 'none'], | ||
'date_time_immutable' => true, | ||
'declare_equal_normalize' => ['space' => 'none'], | ||
'increment_style' => ['style' => 'post'], | ||
'linebreak_after_opening_tag' => true, | ||
'list_syntax' => ['syntax' => 'short'], | ||
'mb_str_functions' => false, | ||
'method_chaining_indentation' => true, | ||
'multiline_whitespace_before_semicolons' => false, | ||
'native_function_invocation' => ['include' => ['@all']], | ||
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true], | ||
'non_printable_character' => false, | ||
'ordered_class_elements' => ['order' => ['use_trait', 'constant', 'property', 'construct', 'magic', 'method']], | ||
'php_unit_internal_class' => false, | ||
'php_unit_method_casing' => ['case' => 'snake_case'], | ||
'php_unit_test_class_requires_covers' => false, | ||
'phpdoc_types_order' => ['null_adjustment' => 'always_last'], | ||
'simplified_null_return' => false, | ||
'single_line_comment_style' => false, | ||
'static_lambda' => true, | ||
'yoda_style' => false, | ||
] | ||
) | ||
->setRiskyAllowed(true) | ||
->setUsingCache(false) | ||
->setIndent(" ") | ||
->setLineEnding("\n") | ||
->setFinder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
includes: | ||
- %rootDir%/../../../vendor/phpstan/phpstan-phpunit/extension.neon | ||
- %rootDir%/../../../vendor/slam/phpstan-extensions/conf/slam-rules.neon | ||
- %rootDir%/../../../vendor/slam/phpstan-extensions/conf/symfony-rules.neon | ||
|
||
parameters: | ||
checkMissingIterableValueType: false | ||
reportUnmatchedIgnoredErrors: false | ||
inferPrivatePropertyTypeFromConstructor: true | ||
|
||
ignoreErrors: | ||
- '#Cannot call method scalarNode() on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface|null#' | ||
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children().#' | ||
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder::root().#' | ||
- '#Class Symfony\\Component\\Config\\Definition\\Builder\\TreeBuilder constructor invoked with 0 parameters, 1-3 required.#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="false" | ||
convertWarningsToExceptions="true" | ||
stopOnFailure="false" | ||
bootstrap="../../vendor/autoload.php" | ||
verbose="true"> | ||
|
||
<testsuites> | ||
<testsuite name="SocialPost Bundle Test Suite"> | ||
<directory>../../tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">../../src</directory> | ||
</whitelist> | ||
</filter> | ||
|
||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"name": "martin-georgiev/social-post-bundle", | ||
"type": "symfony-bundle", | ||
"description": "Symfony bundle for simultaneous posting of the same message to Facebook and Twitter", | ||
"keywords": ["symfony", "bundle", "facebook", "twitter", "facebook sdk for php", "twitter sdk for php", "post create", "social network", "php8"], | ||
"minimum-stability": "stable", | ||
"license": "MIT", | ||
|
||
"authors": [ | ||
{ | ||
"name": "Martin Georgiev", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Yan Rogozinsky", | ||
"email": "[email protected]" | ||
} | ||
], | ||
|
||
"autoload": { | ||
"psr-4": { | ||
"MartinGeorgiev\\": "src/Janwebdev/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\MartinGeorgiev\\": "tests/Janwebdev/" | ||
} | ||
}, | ||
|
||
"require": { | ||
"php": ">=8.1", | ||
"janwebdev/social-post": "^1.0", | ||
"symfony/framework-bundle": ">=v6.4.0", | ||
"symfony/yaml": ">=v6.4.0" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^3.52", | ||
"php-coveralls/php-coveralls": "^2.7", | ||
"phpstan/phpstan": "^1.0", | ||
"phpstan/phpstan-phpunit": "^1.3", | ||
"phpunit/phpunit": "^9|^10|^11", | ||
"sensiolabs-de/deptrac-shim": "^1.0", | ||
"slam/phpstan-extensions": "^6.0", | ||
"symfony/phpunit-bridge": ">=6.4.0" | ||
}, | ||
|
||
"scripts": { | ||
"check-code-style": [ | ||
"php-cs-fixer fix --config='./ci/php-cs-fixer/config.php' --show-progress=none --dry-run --no-interaction --diff -v" | ||
], | ||
"check-security": [ | ||
"security-checker security:check" | ||
], | ||
"fix-code-style": [ | ||
"php-cs-fixer fix --config='./ci/php-cs-fixer/config.php' --show-progress=none --no-interaction --diff -v" | ||
], | ||
"run-static-analysis": [ | ||
"phpstan analyse --configuration='./ci/phpstan/config.neon' --no-progress --level=8 src/ tests/", | ||
"deptrac analyze './ci/deptrac/config.yml' --no-interaction --no-progress" | ||
], | ||
"run-tests": [ | ||
"phpunit --configuration='./ci/phpunit/config.xml'" | ||
], | ||
"run-tests-with-clover": [ | ||
"phpunit --configuration='./ci/phpunit/config.xml' --coverage-clover './build/logs/clover.xml'" | ||
] | ||
}, | ||
|
||
"config": { | ||
"bin-dir": "bin", | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"php-http/discovery": true | ||
} | ||
}, | ||
"prefer-stable": true | ||
} |
Oops, something went wrong.