Code Monkey home page Code Monkey logo

invo's Introduction

INVO Application

Phalcon is a web framework delivered as a C extension providing high performance and lower resource consumption.

This is a sample application for the Phalcon PHP Framework. We expect to implement as many features as possible to showcase the framework and its potential.

Please write us if you have any feedback.

Thanks.

NOTE

The master branch will always contain the latest stable version. If you wish to check older versions or newer ones currently under development, please switch to the relevant branch.

Get Started

Requirements

Installation

  1. Copy project to local environment - git clone [email protected]:phalcon/invo.git
  2. Copy file cp .env.example .env
  3. Edit .env file with your DB connection information
  4. Run DB migrations vendor/bin/phalcon-migrations run --config=migrations.php

If you do not have PHP installed on your machine or do not wish to install it, you can run the application in a docker container. You will need docker and docker-compose.

docker-compose up -d 

will build and start your environment

docker exec -it invo-8.0 /bin/bash

will allow you to enter the environment and run the tests. There is also invo-8.1 as an option, if you wish to run an environment with PHP 8.1.

To see the dockerized invo in action run:

docker inspect invo-8.0

and make a note of the IPAddress. Type the address in your browser and you will see the invo application in action.

Contributing

See CONTRIBUTING.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

Invo is open-sourced software licensed under the New BSD License. © Phalcon Framework Team and contributors

invo's People

Contributors

aircodepl avatar aisuhua avatar alec-w avatar alexwybraniec avatar andresgutierrez avatar arhell avatar brikou avatar cameronhall avatar carvajaldiazeduar avatar delphianer avatar dertin avatar evgesha9400 avatar hyjk2000 avatar igonza avatar jeckerson avatar jpritcha avatar kaiohken1982 avatar kenjikobe avatar mattiasnilsson avatar niden avatar s-ohnishi avatar sergeyklay avatar sergeysviridenko avatar sidroberts avatar simkuns avatar superrosko avatar tugrul avatar ultimater avatar xboston avatar yesworld 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

invo's Issues

V4 Upgrade

We would like to keep supporting Invo in v4. Invo is a great starting point for our users that are learning Phalcon.

phalcon-migrations fails: Syntax error

Issue description

phalcon-migrations fails.

Steps to reproduce the issue

  1. install phalcon on php7.4 & mysql 8.0
  2. clone invo & setup .env
  3. exec vendor/bin/phalcon-migrations migration run --config=migrations.php --verbose in shell

What's the expected result?

Success: Version 1.0.0 was successfully migrated

What's the actual result?

3.3542697305834E+15: CREATE TABLE `invo_phalcon4`.`users` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `username` VARCHAR(32) NOT NULL, `password` CHAR(40) NOT NULL, `name` VARCHAR(120) NOT NULL, `email` VARCHAR(70) NOT NULL, `created_at` TIMESTAMP(1) NOT NULL DEFAULT CURRENT_TIMESTAMP, `active` TINYINT(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ciERROR: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'created_at'

Environment

php7.4 & mysql 8.0

Workaround

apply these changes

'default' => "CURRENT_TIMESTAMP",

'default' => "CURRENT_TIMESTAMP(1)",

'default' => "CURRENT_TIMESTAMP",

'default' => "CURRENT_TIMESTAMP(1)",

Dotenv is necessary?

config/config.php is rewritten from

    'database' => [
        'adapter' => getenv('DB_ADAPTER'),
        'host' => getenv('DB_HOST'),
        'username' => getenv('DB_USERNAME'),
        'password' => getenv('DB_PASSWORD'),
        'dbname' => getenv('DB_DBNAME'),
        'charset' => getenv('DB_CHARSET'),
],

to

    'database' => [
        'adapter'  => $_ENV['DB_ADAPTER'] ?? 'Mysql',
        'host'     => $_ENV['DB_HOST'] ?? 'locahost',
        'username' => $_ENV['DB_USERNAME'] ?? 'phalcon',
        'password' => $_ENV['DB_PASSWORD'] ?? 'secret',
        'dbname'   => $_ENV['DB_DBNAME'] ?? 'phalcon_invo',
        'charset'  => $_ENV['DB_CHARSET'] ?? 'utf8',
    ],

but after the change, $_ENV is referenced and Dotenv is not used, so isn't Dotenv unnecessary?

Also, in .env.example, DB_DBNAME=invo, but the database name is changed like 'dbname' => $_ENV['DB_DBNAME'] ?? 'phalcon_invo', Is it intentional?

use "beforeExecuteRoute" instead of "beforeDispatch" in the Security plugin

The Security plugin should use "beforeExecuteRoute" instead of the "beforeDispatch" event in order to check the ACL.

In case the user tries to access a controller/action that doesn't exist the ACL will report that the client is not allowed to access the said resource, since it wasn't listed in the ACL.

Example:
role: Users -> GET /companies/invalid-action; ACL will report denied, since "invalid-action" wasn't added to the list

"beforeExecuteRoute" event is triggered only after the dispatcher knows that the controller/action exists and will allow 404 errors to be handled.

Small Typo

invo / app / views / companies / search.volt
Line 34:

<td width="12%">{{ link_to("companies/delete/" ~ company.id, '<i class="icon-remove"></i> Delete', "class": "btn") }}></td>

should be:

<td width="12%">{{ link_to("companies/delete/" ~ company.id, '<i class="icon-remove"></i> Delete', "class": "btn") }}</td>

extra > before </td>

INVO does not have order management ?

From @salesiss on November 6, 2017 2:20

Expected and Actual Behavior

INVO sample application does not have or is not showing any order management (create/edit/delete) for 'INVOICES'.

Describe what you are trying to achieve and what goes wrong.
Create, edit, delete and manage invoices.

Provide output if related. Provide coredump if any.

Provide minimal script to reproduce the issue
simply install invo from a fresh php 7.1 / ngnix 1.12 and try to add an invoice.
there was no functionalty avaliable.

// paste code

Details

  • Phalcon version: (php --ri phalcon) 3.2.4
  • PHP Version: (php -v) 7.1.7
  • Operating System: amazon ami ec2 / m3.large
  • Installation type: Compiling from source || installing via package manager
    compiling via source
  • Zephir version (if any):
  • Server: Nginx 1.12.1
  • Other related info (Database, table schema): mysql 5.6 new/fresh install.

something very strange with invo - it s not showing neither edit nor manage invoices - is this normal qt

Copied from original issue: phalcon/cphalcon#13147

Register new User

hello actualy register new user don't work

$request->getPost
need to be change in
$this->request->getPos

my instlation of falcon can create this Bug?
if you have similar bug i can commit It.

regards,

Harksin

All:
$name = $this->request->getPost('name', array('string', 'striptags'));
$username = $this->request->getPost('username', 'alphanum');
$email = $this->request->getPost('email', 'email');
$password = $this->request->getPost('password');
$repeatPassword = $this->request->getPost('repeatPassword');

SecurityPlugin.php Access Control List logic bug

screen shot 2014-12-21 at 11 33 57 pm

this line using '*' as action value would be introduced access control fail. resulting inconsistent access change result in line 110 "$allowed = $acl->isAllowed($role, $controller, $action);"

the code should be changed to as attached.
screen shot 2014-12-21 at 11 37 15 pm

ProductsController.php is not working, bad line in ProductsForm.php

You have a bad code in line 121, $form->isValid($data, $product)
This line causes error 'Internal Error
Something went wrong, if the error continue please contact us'

Even if u disable form validation (from line 121 to line 126 this script is NOT working - does nothing (does not update products even it if say 'Product was updated successfully'.).

Probably same with '!$form->isValid($data, $product)' in line 85 - does not create new product. same error.

There is as well error in line 9 of ProductsForm.php.
Instead 'use Phalcon\Validation\Validator\Numericality;' should be
'use Phalcon\Mvc\Model\Validator\Numericality;'

Anyay the question is how the correct path should look like for all classes (if in this example app this is bad)?

Tested on xampp with phalcon version 1.3.4

register error

image

Table users.active is not null but don't have default value;

Is DB_HOST=localhost correct?

I'm having trouble running migrations.
(I'm trying with the latest v2.0.0)

when I run

vendor/bin/phalcon-migrations list --config=migrations.php

becomes this.

Fatal Error: SQLSTATE[HY000] [2002] No such file or directory

The file .env.example says DB_HOST=localhost and docker-compose.yml looks like this.

 mysql:
   container_name: invo-mysql
   hostname: invo-mysql

Thinking that this is an error that occurs because the host name is different like this, I rewrote .env to DB_HOST=invo-mysql and executed

Phalcon Migrations

┌──────────────────┬───────────────┐
│ Version          │ Was applied   │
├──────────────────┼───────────────┤
│ 1.0.0            │ N             │
└──────────────────┴───────────────┘

It will be displayed.

Again, I think DB_HOST=localhost in .env is incorrect.
Does it have to be localhost for automatic execution of .github/workflows/main.yml?

Wrong requirements for invo v 2.0.0 install

Cannot install latest invo with php version 7.4.33 and Phalcon version 5.0.0

But in release requirements:

Supporting Phalcon v5.0.0+
PHP Versions: 7.4, 8.0, 8.1

composer install/update errors:

    - Root composer.json requires php >=8.0 but your php version (7.4.33) does not satisfy that requirement.
  Problem 2
    - Root composer.json requires PHP extension ext-phalcon ^5.0.2 but it has the wrong version (5.0.0) installed. Install or enable PHP's phalcon extension.
  Problem 3
    - Root composer.json requires codeception/module-phpbrowser ^3.0 -> satisfiable by codeception/module-phpbrowser[3.0.0].
    - codeception/module-phpbrowser 3.0.0 requires php ^8.0 -> your php version (7.4.33) does not satisfy that requirement.
  Problem 4
    - Root composer.json requires codeception/module-asserts ^3.0 -> satisfiable by codeception/module-asserts[3.0.0].
    - codeception/module-asserts 3.0.0 requires php ^8.0 -> your php version (7.4.33) does not satisfy that requirement.
  Problem 5
    - Root composer.json requires phalcon/migrations ^3.0 -> satisfiable by phalcon/migrations[v3.0.0].
    - phalcon/migrations v3.0.0 requires ext-phalcon >=5.0.1 -> it has the wrong version (5.0.0) installed. Install or enable PHP's phalcon extension.
  Problem 6
    - codeception/codeception[5.0.0, ..., 5.0.6] require php ^8.0 -> your php version (7.4.33) does not satisfy that requirement.
    - Root composer.json requires codeception/codeception ^5.0.0 -> satisfiable by codeception/codeception[5.0.0, ..., 5.0.6].

Please fix the description for release.
What version Invo need for install without errors with php version 7.4 ?

Phalcon invo - volt does not compile

New to phalcon, installed phalcon on mac followed instruction, got invo. when loading localhost/invo got Error code: ERR_EMPTY_RESPONSE on chrome. No cache volt.php in invo/cache/volt have already chmod 777 -R invo so it's not access right.
Debugged under phpstorm failure (Process finished with exit code 139) in services.php
line 80 $compiler->addFunction('is_a', 'is_a');

Anyone can help ?

ProductsForm - Numericality Not Found

Fatal error: Class 'Phalcon\Validation\Validator\Numericality' not found in /.../invo/app/forms/ProductsForm.php on line 52

Changed line 9 from:

use Phalcon\Validation\Validator\Numericality;

to:

use Phalcon\Mvc\Model\Validator\Numericality;

Script 'createdb.php' and 'password' field length on 'users' table

The script createdb.php will create the password field of 30 char length but SHA1 hash algorithm, that is used for login, is of 40 char length, so in order to login the user.password field must be altered to length of 40.
Someone else has encountered this problem?

$publicResources

'errors' => array('show404', 'show500')
is 'show401' missed? I did a very brief test, it's going to loop 255 times.

unit testing examples?

Is there a way a complete coverage unit tests could be written for the app? I struggle with how to build out testing for my own apps, and a good example would be well appreciated.

Question

in file ./app/plugins/Security.php
at line number 44
please change comment

minor mistakes

app\plugins\NotFoundPlugin:

"This action is executed before execute any action in the application" may have to change to a more accurate description.


app\config\services.php:

"a user component"


app\config\services.php:

"If the configuration specify the use of metadata adapter use it or use memory otherwise" may have to change to a more accurate description.


app\controllers\RegisterController.php:

"diferent"


app/views/register/index.volt:

is the "input-xlarge" no longer being used? Further more seem like the "repeatPassword" need "form-control".


app/views/errors/show404.volt:

"accesed"


app\plugins\SecurityPlugin:

"session" do not have "registerAction" anymore

errors/show401 report 404 error

class SecurityPlugin->beforeDispatch

$dispatcher->forward(array(
                'controller' => 'errors',
                'action'     => 'show401'
            ));

when I access errors/show401, it displays 404 notfound error.

SyntaxErrror: syntax error in Browser

Directly after cloning it into a directory on my local webserver and opening it in the browser I receive this error related to for jquery.min.js, bootstrap.js and utils.js - see attached screenshot.
screenshot_invo

I'm using Firefox 23.0.1 on Mac OS X with Firebug 1.11.4 installed.

[INVO Bug] One Bug happens when edit an item

When I find out, I saw one bug in INVO project.

This bug happens on all model. It displays wrong notice when edit an item

Scenario:

  • Choose any model, search them. In this scenario, i chose Company
  • Click _Edit_ any item.
  • Clear data of any required row.
  • Click _Save_
  • The notice appear (Something like this: "Name is required")
  • Add info for that required row
  • Click _Save_
  • The notice appear not correctly

Expect notice: Company was updated successfully

Actual notice: Company was created successfully

I think this bug happens because of code:

CompaniesController.php

    $data = $this->request->getPost();
    if (!$form->isValid($data, $company)) {
            foreach ($form->getMessages() as $message) {
                $this->flash->error($message);
            }
            return $this->forward('companies/new');
        }

I'm just a newbie with Phalcon. So how can we fix that?

Thanks so much.

in invo, i test the dispatch event

in Security.php, i find here used befroeDispatch. but i don't found this event in http://docs.phalconphp.com/en/0.7.0/reference/dispatching.html

so i test this; and add beforeDispathLoop, afterDispatch and afterDispatchLoop

    public function beforeDispatch(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher)
    {

        $auth = $this->session->get('auth');
        if (!$auth){
            $role = 'Guests';
        } else {
            $role = 'Users';
        }

        $controller = $dispatcher->getControllerName();
        $action = $dispatcher->getActionName();

        $acl = $this->getAcl();

        $allowed = $acl->isAllowed($role, $controller, $action);
        if ($allowed != Phalcon\Acl::ALLOW) {
            $this->flash->error("You don't have access to this module");
            $dispatcher->forward(
                array(
                    'controller' => 'index',
                    'action' => 'index'
                )
            );
            return false;
        }

    } 
    public function beforeDispatchLoop(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) {
        $this->flash->error('beforeDispatchLoop');
    } 

    public function beforeExecuteRoute(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) {
        $this->flash->error('beforeExecuteRoute');
    }

    public function beforeExecute(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) {
        $this->flash->error('beforeExecute');
    }

    public function afterExecuteRoute(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) {
        $this->flash->error('afterExecuteRoute');
    }

    public function beforeNotFoundAction(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) {
        $this->flash->error('beforeNotFoundAction');
    }

    public function afterDispatch(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) {
        $this->flash->error('afterDispatch');
    }

    public function afterDispatchLoop(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) {
        $this->flash->error('afterDispatchLoop');
    }

i visit a backend url, like http://invo.com/products/index

order list result is :

beforeDispatchLoop

You don't have access to this module

beforeExecuteRoute

This is a sample application of the Phalcon PHP Framework. Please don't provide us any personal information. Thanks // this line is excute action result

afterExecuteRoute

afterDispatch

afterDispatchLoop

but i edit invo code beforeDispatch to beforeDispatchLoop , the page is blank。code is:

    public function beforeDispatchLoop(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher)
    {

        $auth = $this->session->get('auth');
        if (!$auth){
            $role = 'Guests';
        } else {
            $role = 'Users';
        }

        $controller = $dispatcher->getControllerName();
        $action = $dispatcher->getActionName();

        $acl = $this->getAcl();

        $allowed = $acl->isAllowed($role, $controller, $action);
        if ($allowed != Phalcon\Acl::ALLOW) {
            $this->flash->error("You don't have access to this module");
            $dispatcher->forward(
                array(
                    'controller' => 'index',
                    'action' => 'index'
                )
            );
            return false;
        }

    } 
    public function beforeDispatch(Phalcon\Events\Event $event, Phalcon\Mvc\Dispatcher $dispatcher) {
        $this->flash->error('beforeDispatch');
    } 

two question:

  1. beforeDispatch, afterDispatch is the Name Conventions of dispatch event ?
  2. why i edit beforeDispatch's order , page show blank page ?

Fatal error during migration

I did the following for the migration.

vendor/bin/phalcon-migrations run --config=migrations.php

Then the following message is displayed.

Fatal Error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1' for key 'PRIMARY'

I don't understand it well, so I put
echo __CLASS__,'::',__FUNCTION__,':',__LINE__,PHP_EOL;
in many places and executed it, and the result is as follows.

Phalcon\Migrations\Console\Commands\Migration::run:102
Phalcon\Migrations\Migrations::run:387
Phalcon\Migrations\Mvc\Model\Migration::migrate:317
CompaniesMigration_100::afterCreateTable:115
Phalcon\Migrations\Mvc\Model\Migration::batchInsert:800
/srv/vendor/phalcon/migrations/src/Mvc/Model/Migration.php:903:
string(178) "INSERT INTO companies (id,name,telephone,address,city) VALUES ('1','Acme','31566564','Address','Hello'),('2','Acme Inc ','+44 564612345','Guildhall, PO Box 270, London','London');"
Phalcon\Migrations\Mvc\Model\Migration::migrate:324
CompaniesMigration_100::up:88
Phalcon\Migrations\Mvc\Model\Migration::batchInsert:800
/srv/vendor/phalcon/migrations/src/Mvc/Model/Migration.php:903:
string(178) "INSERT INTO companies (id,name,telephone,address,city) VALUES ('1','Acme','31566564','Address','Hello'),('2','Acme Inc ','+44 564612345','Guildhall, PO Box 270, London','London');"

It seems that afterCreateTable() and up() are called in succession in Migration::migrate.
(each calling batchInsert() )

Is this because these two are defined in companies.php?
Or is it a bug in phalcon/migrations?

Should the DB instance be shared

Shouldn't the DB instance in index.php dependency injector be a shared instance? I noticed in my own testing that it drastically reduces the number of connections per request.

icon is not displayed

Invo uses bootstrap4.4.1 and uses <i class="glyphicon glyphicon-edit"></i> in .volt.
However, bootstrap4 and newer do not include icons by default, and other icons (eg icons.getbootstrap.com or Font Awesome) cannot be used in the same way as v3.

Phalcon/INVO not too fond of tilde (~) characters in config.ini

Hi Phalcon Devs,

I use CPanel and its password generator uses several special characters for security, including the ~ character. Unfortunately placing that password into the config file for INVO will cause the config.ini parser to fail.

I got round the issue by moving the database config from config.ini into the bootstrap so it's not a high priority but it would probably be better if the parser could handle it rather than die.

Many thanks for your hard work.

Exception: Serialization of 'Closure' is not allowed

In the searchAction of the controller, it is stored in Session/Bag as follows.
However, the array returned by getParams() contains di, and Closure exists in it, so it cannot be serialized, so it fails to save to the session.

$this->persistent->searchParams = $query->getParams();

This failure can be avoided by excluding the key di from the array returned by getParams().
for example

             $params = $query->getParams();
             unset($params['di']);
             $this->persistent->searchParams = $params;

or

$this->persistent->searchParams = array('di'=>null) + $query->getParams();

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.