Giter Club home page Giter Club logo

incubator's Introduction

Phalcon Incubator

Build Status Latest Version Software License Total Downloads Daily Downloads

This is a repository to publish/share/experiment with new adapters, prototypes or functionality that can potentially be incorporated into the Phalcon Framework.

We also welcome submissions of snippets from the community, to further extend the framework.

The code in this repository is written in PHP.

Installation

Installing via Composer

Install Composer in a common location or in your project:

curl -s http://getcomposer.org/installer | php

Then create the composer.json file as follows:

{
    "require": {
        "phalcon/incubator": "^3.4"
    }
}

If you are still using Phalcon 2.0.x, create the composer.json file as follows:

{
    "require": {
        "phalcon/incubator": "^2.0"
    }
}

Run the composer installer:

$ php composer.phar install

Installing via GitHub

Just clone the repository in a common location or inside your project:

git clone https://github.com/phalcon/incubator.git

For a specific git branch (eg 2.0.13) please use:

git clone -b 2.0.13 [email protected]:phalcon/incubator.git

Autoloading from the Incubator

Add or register the following namespace strategy to your Phalcon\Loader in order to load classes from the incubator repository:

$loader = new Phalcon\Loader();

$loader->registerNamespaces(
    [
        'Phalcon' => '/path/to/incubator/Library/Phalcon/',
    ]
);

$loader->register();

Testing

Tests are located in tests/ and use Codeception. See tests/README.md.

Contributing

See CONTRIBUTING.md.

Contributions Index

See INDEX.md.

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

License

Incubator is open-sourced software licensed under the New BSD License.
© 2011-2018, Phalcon Framework Team

incubator's People

Contributors

blocklogic-au avatar cameronhall avatar cottton avatar davihu avatar digitronac avatar endeveit avatar fenikkusu avatar gnumoksha avatar green-cat avatar igusev avatar jeckerson avatar jurigag avatar kachit avatar korsar-zn avatar micheleangioni avatar nexik avatar niden avatar parshikov avatar pyyoshi avatar sergeyklay avatar sergeysviridenko avatar sgenov avatar sidroberts avatar sjinks avatar stibiumz avatar thehe avatar tmihalik avatar ulfims avatar xboston avatar yerlenzhubangaliyev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

incubator's Issues

Translate/Adapter/Gettext.php substition don't work anymore

Hi,

with the new version this don't work any more:

$translate = new Phalcon\Translate\Adapter\Gettext(array(
    'locale' => 'fr_FR',
    'file' => 'messages',
    'directory' => '../app/lang'
));
echo $translate->_('My name is %name%', array('name' => 'Peter')); 

The Result:
My name is %name%

I think the problem is line 93ff
It has to be:

        if ($domain === null) {
            $translation = gettext($index);
        } else {
            $translation = dgettext($domain, $index);
        }
        if (is_array($placeholders)) {
            foreach ($placeholders as $key => $value) {
                $translation = str_replace('%' . $key . '%', $value, $translation);
            }
        }

        return $translation;

Pager does not have access to total item count

Pager does not have access to total item count

paginateResult is declared as protected so there is no way to obtain total item count.

Posible solution :
add method:

/**
 * Return total number of items.
 *
 * @return integer
 */
public function getTotalItems()
{
    return $this->paginateResult->total_items;
}

Coding style

Hello everyone.
In #79 @tmihalik changed the code indention to tabs instead of spaces.
This is violates PSR-2.
I believe that project should follow accepted community standards.
If community members vote for it, I'll run a php-cs-fixer on the sources.
Also maybe we should setup jenkins ci with PHP_CodeSniffer?
@phalcon @xboston @niden @sjinks

Why the cache content using Twig doesn't get created?

In my service I have this:

$di->set('view', function() use ($config) 
{
    $view = new \Phalcon\Mvc\View();
    $view->setViewsDir($config->application->viewsDir);
    $view->registerEngines(array(
        '.volt'     => function($view, $di) use ($config) {
            $volt = new VoltEngine($view, $di);
            $volt->setOptions(array(
                'compiledPath' => $config->application->cacheDir,
                'compiledSeparator' => '_',
                'compileAlways' => true
            )); return $volt;
        },
        '.phtml'    => 'Phalcon\Mvc\View\Engine\Php',
        '.php'      => 'Phalcon\Mvc\View\Engine\Php',
        '.twig'     => function($view, $di) {
            $options = ['cache' => $config->application->cacheDir ]; //Setting up Twig Environment Options
            $twig = new \Phalcon\Mvc\View\Engine\Twig($view, $di, $options);
            return $twig;
        }
    ));
    return $view;
}, true);

Twig work's fine showing the content, but I wanna cache the content inside my directory $config->application->cacheDir, volt work's great and create the "compiled" files, but why twig doesn't if I'm passing the correct option cache = directory....?

Thank's for help..! :)

Phalcon/Cache/Backend/Memcached.php is NOT Memcached

Contrary to it's name, Phalcon/Cache/Backend/Memcached.php is using the Memcache extension, NOT the Memcached extension. This should either be renamed or rewritten as these are not the same thing and will cause further confusion of an already confusing topic.

use Memcache as NativeMemcache;

$this->_memcache = new NativeMemcache;

No encoding defined in Gettext Translation adapter

In file line codes:
https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Translate/Adapter/Gettext.php#L77
putenv("LC_ALL=" . $options['locale']);
https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Translate/Adapter/Gettext.php#L78
setlocale(LC_ALL, $options['locale']);

There is no encoding defined, that will cause problems with some functions like htmlentities or json_encode for sites that use UTF-8 encoded contents because you are override the environment encoding.

I solved my problem in my site by doing this:
putenv("LC_ALL=" . $options['locale'].'.utf8');
setlocale(LC_ALL, $options['locale'].'.utf8');

Version / Release

Hi,

can you add tags on incubator so that composer depends on this version ?

Doing this we could update incubator when we update phalcon so that class which will be integrated inside the C version disappear from the incubator version.

Regards

Deleting Values from session doesn't work, when no data is left.

I found this when setting flash messages and they were the only data in the session. The flash messages would stay over and over again. This is because the class does not allow all data/variables to be removed, as you are checking data for empty.

In Phalcon\Session\Adapter\Database.php,

public function write($sessionId, $data)
    {
        if ($this->isDestroyed || empty($data)) {
            return false;
        }

should be...

public function write($sessionId, $data)
    {
        if ($this->isDestroyed) {
            return false;
        }

So that data variables can be deleted, and written back to the session/db.

Composer autoloader

Since we like Phalcon and composer, we're using both of them.

What I don't like is to have two different autoloaders so I wrote this part of code (which i'm not very proud of), to be able to use Phalcon autoloader instead of composer one :

$loader = new \Phalcon\Loader();
$namespaces = [
   // internal namespaces which could also be done proper using composer.json
];
}
// get namespaces from Composer
$map = require $config->application->vendorDir . 'composer/autoload_namespaces.php';
foreach ($map as $k => $values) {
    $k = trim($k, '\\');
    if (!isset($namespaces[$k])) {
        $dir = '/' . str_replace('\\', '/', $k) . '/';
        $namespaces[$k] = implode($dir . ';', $values) . $dir;
    }
}
$loader->registerNamespaces($namespaces);

$classMap = require $config->application->vendorDir . 'composer/autoload_classmap.php';
$loader->registerClasses($classMap);

$loader->register();

this code doesn't take care of PSR4 composer parts, but at this time it does the job.

What do you think of it ?

@phalcon : I've got one problem with it, Phalcon loader seems to lack the ability to have multiple dir for the same namespace which exists in composer.
At this time i've got incubator & dev-tools in my projet, so one of the two projects is not treated in this autoloader. Is it me or does phalcon lacks this functionality ?

Phalcon\Logger\Adapter\Firephp: Error

I've a problem with the FirePHP-Logger.
It looks like it always use the FirePHP-Logger inside Phalcon and not the incubator class.

This is the error:
["There was a problem wri...ePHP/FirebugConsole/0.1",
TypeError: mode is undefined
Filtered chrome url chrome://firephp/content/lib/renderer.js
]

I'm using phalcon 1.2.3

Bad number of parameters in Phalcon\Config\Adapter\Yaml

If I use the "Phalcon\Config\Adapter\Yaml" class from the incubator as described in the readme:

define('APPROOT', dirname(__DIR__));
define('CONFKEY', 'secret');

$config = new Phalcon\Config\Adapter\Yaml('path/config.yml', array(
    '!decrypt' => function($value) {
        return (new Phalcon\Crypt)->setCipher('blowfish')->decryptBase64($value, CONFKEY);
    },
    '!approot' => function($value) {
        return APPROOT . $value;
    }
));

echo $config->phalcon->controllersDir;
echo $config->database->username;
echo $config->database->password;

I am getting an error:

BadMethodCallException: Wrong number of parameters

Stack trace:

#0 Phalcon\Config\Adapter\Yaml->__construct(/usr/share/nginx/phalcon-services/config/config.yml, Array([!decrypt] => Object(Closure), [!approot] => Object(Closure)))

However, if instead I manually load the yml file in an array $result and then pass it to a Phalcon\Config constructor, everything works (basically, do the same thing that the adapter does in my index.php inside the public folder).

Also, if I dump the callbacks array, it works as well but obviously without having the values processed by the closure functions. I am not sure why I get that exception when I pass the closures to the adapter.

I am using:

PHP Version 5.4.4-14+deb7u14
YAML module 1.1.1
Phalcon 1.3.2

isAllowed in Phalcon\Acl\Adapter\Database not working for postgresql

Tried to use Phalcon\Acl\Adapter\Database with Postgresql which failed on the isAllowed function. The SQL SELECT statement is not compatible with Postgresql because by default you cannot do math with boolean values. This can be fixed by changing the ORDER BY clause:

ORDER BY (roles_name != '*')::int+(resources_name != '*')::int+(access_name != '*')::int DESC

but I assume this will break MySQL/SQLite ?

Phalcon\Http\Client\Provider\Curl can't upload image file

Here is my environment:
php - v5.5.14
curl - v7.30.0
php-curl - v5.5.14
phalcon - v1.3.2
os - mac osx v10.9.3

I got the image as an array instead of a file in the remote when I upload an image file by Phalcon\Http\Client\Provider\Curl.
But I can uploaded it by the default curl which built-in php.

I guess the difference of them(the two way) may be the options of the CURLOPT.
I'm trying to location problem but I could not got it.

Hope someone can find and solve the problem, thank you all.

Note: in php >= 5.5, we must use CURLFile instead of '@'.

Missing $context from Phalcon\Logger\Adapter::logInternal method

Fatal error: Declaration of Phalcon\Logger\Adapter\Database::logInternal() must be compatible with Phalcon\Logger\Adapter::logInternal($message, $type, $time, $context) in /var/www/vendor/phalcon/incubator/Library/Phalcon/Logger/Adapter/Database.php on line 10

We need to add $context so this class can be compatible with Phalcon 1.3.0

Translate Gettext - Already in Phalcon 1.3.2

The \Phalcon\Translate\Adapter\Gettext class is already in Phalcon 1.3.2, but with a bit different configuration like e.g. defaultDomain. Could all options be moved to Phalcon and then this be renamed or removed and documented on Phalcon? This is causing a conflict, as application is taking by default class from Phalcon.

the requested PHP extension phalcon has the wrong version (1.3.2) installed

{
"require": {
"phalcon/incubator": "v1.2.5"
}
}

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for phalcon/incubator v1.2.5 -> satisfiable by phalcon/incubator[v1.2.5].
- phalcon/incubator v1.2.5 requires ext-phalcon 1.2.5 -> the requested PHP extension phalcon has the wrong version (1.3.2) installed.

i tried to require v1.3.2 but its not exists .

Phalcon\Queue\Beanstalk\Extended::getTubes() hangs blocking

getTubes() calls getResponseLines() which calls Phalcon\Queue\Beanstalk::write('list-tubes') and tries to read the result. The write never returns and hangs forever.

using PHP 5.5 on Centos 6.5
http://phalcon.agent-j.ru/en/1.3.0/Phalcon/Queue/Beanstalk#write-details claims Phalcon\Queue\Beanstalk::write takes now args

I've run the unit test in cphalcon (Output below) and everything works. My beanstalkd server is running fine and I can add jobs to the queue via putInTube and see them when I telnet to the services and look in the queue.

phpunit BeanstalkTest.php
PHPUnit 3.7.29 by Sebastian Bergmann.
..
Time: 260 ms, Memory: 2.50Mb
OK (2 tests, 16 assertions)

typo error in gettext adapter

line 73, there is a double semi column:
$translation = gettext($index);;

(will have to learn github a bit more to know how to submit a patch) !

Mustache template can't call PHP magic methods

Hi guys,
I'm having a weird issue with Phalcon and Mustache templates.

I created a PHP class that have private attributes and I created the __get() magic in order to get them.

Even if from PHP everything works fine, in the mustache code it seems it doesn't use the magic method __get...

Please help me. Is anybody experiencing the same issue?
thanks!

Twig implementation of "assets tags

Hello,

I try to use assets addCSS and addJS but it doesn't work, and I would like to know the difference between theses two and stylesheetLink / javascriptInclude function added to Twig. The last two functions work exactly as the volt implementation work (using asset service).

Is the asset tag work correctly ?
What the difference with stylesheetLink / javascriptInclude function ?

Thanks

Incubator doesn't work for me with composer when using Phalcon 1.3.3.

dschissler@box:~/test$ composer require phalcon/incubator
Using version ~1.2 for phalcon/incubator
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - phalcon/incubator v1.2.5 requires ext-phalcon 1.2.5 -> the requested PHP extension phalcon has the wrong version (1.3.3) installed.
    - phalcon/incubator 1.2.4 requires ext-phalcon 1.2.4 -> the requested PHP extension phalcon has the wrong version (1.3.3) installed.
    - Installation request for phalcon/incubator ~1.2 -> satisfiable by phalcon/incubator[1.2.4, v1.2.5].


Installation failed, deleting ./composer.json.

SessionDatabaseAdapter::remove() doesn't work [solved]

When calling $this->session->remove('feedback'), the session isn't getting updated.

My bootstrap.php:

$DI->setShared('session',function() use($DI){
    $Session = new \LOID\Component\SessionDatabaseAdapter([
            'db'        =>  $DI->get('db'),
            'table'     =>  'session_data'
        ]
    );

    $Session->start();
    return $Session;
});

My code simply calls:
$this->session->remove('feedback');

I'm pretty sure I've set everything up correctly, because calls to $this->session->has()/set()/get()/destroy() all function as expected.

I'm not sure if the problem lies with this class, Phalcon, or (more than likely) me.

Documentation for Beanstalkd\Extended is broken

Documentation at https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Queue/Beanstalk gives an example script to monitor the queue. It makes a reference to $beanstalk when it should use $queue as in the example below. I've also reported a second issue that this Class is broken as getTubes() which is used in the foreach is broken and hangs forever.

#!/usr/bin/env php
 '192.168.0.21',
    'prefix' => $prefix,
));

foreach ($queue->getTubes() as $tube) {
    if (0 === strpos($tube, $prefix)) {
        try {
            $stats = $queue->getTubeStats($tube);
            printf(
                "%s:\n\tready: %d\n\treserved: %d\n",
                $tube,
                $stats['current-jobs-ready'],
                $stats['current-jobs-reserved']
            );
        } catch (\Exception $e) {
        }
    }
}

#12 cdn Bug

New it work, but not as expected! Do not load the file at the time of use, in modmencie call {{content ()}}! It can not be, method becomes totally not useful, it is better to use level layouts now!

And plzz change engine twig:
https://gist.github.com/Cmssspl/4690638
I stated earlier this file, do not know why you use only one version, not the current one. :/

composer install and update error

I'm getting the following error
annwsbx

phalcon version : 1.2.6

composer.json is a

{ "require":{ "phpmailer/phpmailer": "v5.2.7", "phalcon/incubator": "v1.2.5" } } Problem 1 - Installation request for phalcon/incubator v1.2.5 -> satisfiable by phalco n/incubator[v1.2.5]. - phalcon/incubator v1.2.5 requires ext-phalcon 1.2.5 -> the requested PHP e xtension phalcon is missing from your system.

Implement Phalcon\Cache\BackendInterface::flush in REDIS class

Please implement flush method so Redis class can be compatible with Phalcon 1.3.0

Fatal error: Class Phalcon\Cache\Backend\Redis contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Phalcon\Cache\BackendInterface::flush) in /var/www/vendor/phalcon/incubator/Library/Phalcon/Cache/Backend/Redis.php on line 163

Translate Gettext method names are too general for xgettext

Rather than add specific view format parsers and ballooning out my project dependencies and making it much more difficult to setup I am instead pointing xgettext at the compiled Volt views on the server side and the compiled views in the webpack bundle for the client side.

In general I think that having very generally named methods like "query" is a good thing but in this particular case it makes it much less useful since xgettext would get a very large number of incorrect hits by looking for functions and methods named 'query'. I propose that it be called something like "translate_query".

I want to name the singular and plural function calls the same in both Javascript and PHP so that the same "--keyword=FUNCTION_NAME" xgettext switches can be used for both languages to minimize setup complexity.

$di and $config not passed in setUp methods on functional and model test case

Getting following message when running phpunit on app using \Phalcon\Test\FunctionalTestCase:

Strict standards: Declaration of Phalcon\Test\ModelTestCase::setUp() should be compatible with Phalcon\Test\UnitTestCase::setUp(Phalcon\DiInterface $di = NULL, Phalcon\Config $config = NULL)

Seems FunctionalTestCase and ModelTestCase are not passing $di and $config params to parent setUp methods

ConfirmationOf

EqualTo is a better name for ConfirmationOf validator.

Also please: password_confirmation -> passwordConfirmation

Phalcon\Mvc\Model\Validator\ConfirmationOf appends two messages

The confirmationOf validator class appends two messages to the model which means that when looping validation messages the confirmation failure is printed twice.

This could be avoided by checking which of the messages had already been output and skipping some, however I think that the error message should only be stored once.

I suppose the reason the message is appended twice is so that it is referenced against each of the fields. I would suggest that the message is only attached to the confirmation field seeing as this is the only field that has really failed validation.

Logout doesn't work with Session Database Adapter

Adapter and DI:

$di->set('session', function() {

    // Create a connection
    $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array(
        "host" => "localhost",
        "username" => "root",
        "password" => "secret",
        "dbname" => "session"
    ));

    $session = new Phalcon\Session\Adapter\Database(array(
        'db' => $connection,
        'table' => 'session_data'
    ));

    $session->start();
    return $session;
});

Logout action:

public function logoutAction()
{
    //todo FIX logout.
    $this->session->destroy();
    $this->response->redirect();
}

After logging out sesion creates immediately with the same values:

279 Connect root@localhost on session
279 Query   SELECT * FROM session_data WHERE session_id = '1b9l1f5qbjbc2hsj7iitqrv944'
279 Query   DELETE FROM session_data WHERE session_id = '1b9l1f5qbjbc2hsj7iitqrv944'
279 Query   SELECT COUNT(*) FROM session_data WHERE session_id = '1b9l1f5qbjbc2hsj7iitqrv944'
279 Query   INSERT INTO session_data VALUES ('....', 1370799347, 0)
279 Quit

With phpredis adapter everything is Ok.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.