Code Monkey home page Code Monkey logo

docs's Introduction

PHPixie PHP Framework

Website: phpixie.com

PHPixie started as a micro framework and has gradually grown to be one of the most popular fullstack PHP frameworks while retaining its high performance. This is in part because of the strict architecture that avoids common pitfalls such as reliance on static methods, global scope, singletons and other antipatterns, thus also ensuring that the code is easy to read, debug, extend and test. In fact, all PHPixie components boast full unit test coverage. This PHP framework never stands in your way and provides you with full control over execution flow. It's easy to learn and straightforward to master.

But it's not all just about the code. The PHPixie community is very friendly and helpful—you can expect an answer to your question within minutes of asking it in the chat. The framework documentation is full of examples and is regularly updated with tutorial videos.

Demo

Want to see an example? Check out a simple base project implementing user and administrator authorization: https://github.com/phpixie/project-auth

Project Demo

PHPixie will fit both newcomers and experienced architects providing ease of use, solid foundation and total flexibility.

Highlights

  • Great performance - Designed for speed while not compromising on features. Proven by independant benchmarks.
  • Bundle System - Reuse and share your code via Composer as self contained bundles
  • Linear code flow - Never find yourself in an event hell ever again as event use is avoided
  • MongoDB Support - Database components support working with MongoDB out of the box, including relationships between SQL databases and Mongo collections.
  • Best Practices - Designed from scratch according to SOLID principles and industry standards.
  • Hardened Security - Using cryptographically secure hashes, random tokens and secure cookie handing.
  • Developer support - Need help? Just drop a line in the chat and get help from the creator in no time.

docs's People

Contributors

dracony avatar xxxwww avatar

Watchers

 avatar  avatar  avatar

docs's Issues

3.0 documentation fix: QuickStart page

When I was trying to learn PHPixie, I was faced with some lacks in documentation (v3.0). Certainly, I started from:

  • https://phpixie.com/quickstart.html - original
  • https://habrahabr.ru/post/320056/ - russian translation
    They are the same and have the same lacks that I cannot fork on github and fix it with my own efforts, so I will leave my thoughts here:
  • syntax misprints, for example out database strructure.
  • when you define route (after phrase Let’s define it as the default one and also add a shortcut route for the frontpage) you wrote frontpage route AFTER processor route, but routes are processed from top to bottom (am I wrong?) so EMPTY path will intercept processor route (it can have empty processor part) and frontpage route won't work. There will be nothing serious until user wish to change frontpage controller to something else...
  • As mentioned this doesn’t work on Windows - this is wrong, symlinks are supported on Windows completely from Windows 2000 (can you find older system? take a cookie!), but named "junction points". In russian, you can read https://geektimes.ru/post/50878/ - shortly, there is command fsutil (but stupid Microsoft make it usable only under administator account). For usage under limited account, use Far manager (almost any version) and Alt+F6 shortcut. This instruction may be inserted in console processor.
  • need to create the app:messages template - previous variant was better: start with the general parent layout /bundles/app/assets/template/layout.php - in this variant, I may not understand, where target file should be located (may be in /bundles/app/src, where I created file recently).
  • Now the repository: - again, where the target file should be located?
  • instead of copy pasting the entire code here let’s look at a single form field - again, no file name,where this code must be located. Later, there are some code examples, where user should guess, where file with this code should be located.
  • in our case it will be http://localhost.com/socialAuth/callback/twitter - are you sure, that localhost.com? Maybe, localhost?
  • That’s it we are donw - misprint
  • there are no information about: what config files can exists in framework, where they should locate and what type of information can contain. Also, I found, that words about config's lazy load is not fully correct: I create assets\config\social.php file with single command die('123'); and script dies. But I didn't use social auth yet!

Absent documentation about configuration

As for me, configuration retreiving is the hardest thing in PHPixie to understand. Documentation about configuration absent, so any analysis can be performed only by source code. Examples:

Local config

I call "local", because this configuration settings are specific to bungle. All example pieces of code ececuted in action (HTTPProcessor). For example, this data will be read from bundles\app\assets\config\pony.php:

$value=$this->builder->bundleConfig()->get('pony.princess')

Or better way to receive two or more values:

$cfg=$this->builder->bundleConfig()->slice('pony');
$value=$cfg->get('princess');

Ok, but this method is not described in documentation. I wanted to use it as i18n tool, retreiving translation strings.

Global config

I call "global", because this configuration settings are common for all bundles. Again, all pieces of code are running in scope of action (HTTPProcessor). For example, this data will be read from assets\config\pony.php

$value=$this->builder->frameworkbuilder()->configuration()->config()->get('pony.princess');

Or better way to receive two or more values

$cfg=$this->builder->frameworkbuilder()->configuration()->config()->slice('pony');
$value=$cfg->get('princess');

But this code is ugly! This $this->builder->frameworkbuilder()->configuration()->config() of anomalous length? It was better to create shortcut, $this->builder->appConfig()->get(...). For myself, I, certainly, did it, here is a solution:

// bundles/app/src/HTTP/Processor.php
	public function __get($name){
		if($name==='bundleConfig')
			return $this->builder->bundleConfig();
		if($name==='appConfig')
			return $this->builder->frameworkbuilder()->configuration()->config();
		if($name==='frameworkBuilder')
			return $this->builder->frameworkBuilder();
		$components=$this->builder->components();
		if(method_exists($components,$name))
			return call_user_func(array($components, $name)); 
		$trace = debug_backtrace();
		trigger_error(
			'Неопределенное свойство в '.get_class($this).': ' . $name .
			' в файле ' . $trace[0]['file'] .
			' на строке ' . $trace[0]['line'],
			E_USER_NOTICE
		);
		return null;
	} 

After this trick, I can get configuration and components like this:

$orm=$this->orm;
$bundleValue=$this->bundleConfig->get('pony.princess');
$appValue=$this->appConfig->get('pony.princess');

So, the pony solution is more beautiful, than pixie, isn't it?

Override configuration

Another mess with configuration in PHPixie. Is there a shortcut method to get hierarchy config data? For example: I wish to create a forum bundle. I put content of this bundle into bundles/forum folder, add link to it into src/Project/Framework/Bundles.php and wish to configure it. A forum has local config, located in bundles/forum/assets/config/forum.php, it contains "default" values, like default page title, default banner and so on. A user may wants to override some of data, like default banner (maybe, depending on selected language or moon's phase). This is like an overlay, but target bundle (forum) shouldn't know about it.
This behaviour was default in Kohana framework: core-specific values can be overridden by module-specific values (the same as bundle) and both of them can be overridden by application-specific values. This works for i18n too. But the great disappointment was that Kohana reads all configuration files at startup and it wasn't very fast. But there were one great advantage: you may see EVERY configuration option in file, copy them into application/config folder and change everything you want (or delete values, that you didn't plan to change, they will be read automatically).
Has PHPixie such convinient instrument? Configuration overlay is slightly different, they mush be merged manually, not automatic.

Assets

Some strange things happens. As I thought, assets is parts of the project, which are not a code (images, css, templates, config and so on). So, the location of such files is very important. But the documentation has many lacks.
For example, in bundles/app/assets/config/templateLocator.php, there is a line:

'directory' => 'templates',

But there are no instruction, why I should use EXACTLY this type of code? Why this:

'directory' => realpath(__DIR__.'../templates'),

will lead to error, because engine cannot find template? This is absolute path to template folder, so it should work perfect!
OK, return to our assets. A code:

$path=$this->builder->assetsRoot()->path();

is not described in documentation, gives us full path to bundles\app/assets/ - good. But if I want to receive global assets, the same code lead to a fail:

$path=$this->builder->frameworkbuilder()->assets()->frameworkAssetsRoot()->path('');

This retreive invalid path: vendor\phpixie\framework\assets/. I wish simple path to /assets.

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.