Open dnaloco opened 8 years ago
familia@familia-C14CU41TV:~/Sites/agenciadigitala.local$ composer require tuupola/slim-jwt-auth
Using version ^2.3 for tuupola/slim-jwt-auth
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing tuupola/slim-jwt-auth (2.3.1)
Downloading: 100%
Writing lock file
Generating autoload files
familia@familia-C14CU41TV:~/Sites/agenciadigitala.local$ composer require vlucas/phpdotenv
Using version ^2.4 for vlucas/phpdotenv
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing vlucas/phpdotenv (v2.4.0)
Downloading: 100%
Writing lock file
Generating autoload files
familia@familia-C14CU41TV:~/Sites/agenciadigitala.local$
http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#jtiDef
https://github.com/Seldaek/monolog
Using version ^1.21 for monolog/monolog
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing monolog/monolog (1.21.0)
Downloading: 100%
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
Writing lock file
Generating autoload files
Autenticação com Tokens Usando AngularJS & NodeJS http://code.tutsplus.com/pt/tutorials/token-based-authentication-with-angularjs-nodejs--cms-22543
Como criar uma API RESTfull em NodeJS e autenticar usando JSON Web Token JWT? http://rcdevlabs.github.io/2015/02/12/como-criar-uma-api-restfull-em-nodejs-e-autenticar-usando-json-web-token-jwt/
https://github.com/auth0/angular-jwt
npm install angular-jwt --save-dev
angularjs-gulp-browserify-boilerplate@1.7.0 /home/familia/Sites/agenciadigitala.local
├── angular-jwt@0.1.3
└── UNMET PEER DEPENDENCY istanbul@~0.3.0
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14
npm WARN karma-coverage@0.2.6 requires a peer of istanbul@~0.3.0 but none was installed.
familia@familia-C14CU41TV:~/Sites/agenciadigitala.local$
public function someAction() { $viewModel = new ViewModel(); $viewModel->setTemplate('MODULE / CONTROLLER / ACTION.phtml'); // In this given example: $viewModel->setTemplate('foo/bar/some.phtml');
// Do some other Controller-logic as used to
return $viewModel->setVariables(array(
//key-value-paired view-variables
));
} ZF2 Performance QuickTipp #2 - Classmap Autoloading This probably is one of the most important parts of speeding up your application. Personally i've seen an increase in LoadingTimes by up to 40%. Implementing this is pretty simple:
class Module { public function getAutoloaderConfig() { return array( 'Zend\Loader\ClassMapAutoloader' => array( DIR . '/autoload_classmap.php', ), ); } } The autoload_classmap.php then is a simple array of 'FQ-CLASSNAME' => 'FQ-FILEPATH'. This can be automatted pretty easily using the classmap_generator-utility of ZF2 ZF2 Performance QuickTipp #3 - Keep Module.php light! Sadly this is a post i haven't come around to write yet. The Module.php is a file that is loaded on every single request. Lots of people forget about this and write lots and lots of factories inside them. At one point, ZfcUser-Module.php was an example of what not to do. Closures or anonymous functions are executed on every request, too. This is quite a bit of work to be done if there's too many of them over the whole project. A better approach would be to simply write Factory-Classes. ZfcUser later updated Module.php to use this strategy.
down vote If you are using Doctrine, don't forget to add a cache for annotations. This drastically improve performance (when I activate this cache I divide nearly by two the loading time). If you are using DoctrineORMModule:
'doctrine' => array( 'driver' => array(
'cache' => array(
'class' => 'Doctrine\Common\Cache\ApcCache'
),
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'apc',
'query_cache' => 'apc',
'result_cache' => 'apc'
)
),
)
) However, it's quite inconvenient while developing because you must clear the cache whenever your mapping change.
composer require learnzf2/route-cache:dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing learnzf2/route-cache (dev-master dfbc0b6)
Cloning dfbc0b604fca04a917d425bc6c1404aca36963ec
Writing lock file
Generating autoload files
familia@familia-C14CU41TV:~/Sites/agenciadigitala.local$
25 down vote the ZF2 classmap generator will give you a big boost if you have a large project:
http://framework.zend.com/manual/2.0/en/modules/zend.loader.classmap-generator.html
Alternatively if you are using composer (you should do) then you can use composer to generate the classmap for all your modules and dependdencies too which is even better:
php composer.phar install --optimize-autoloader
php composer.phar update --optimize-autoloader
First of all to speedup your zf2 application you should use ZendOptimizerPlus. The vast part of execution time used to read and precompile php code. Typical ZF2 app has a lot of files, so it takes a lot of time to handle them.
ZendOp+ saves bytecode of your php application in shared memory, so server doesn't read a lot of files and doesn't parse it every request. ZendOp+ will be at php5.5 by default, so it is useful to know it and to use it.
Benchmarks gives 9x increase in performance for simple framework applications (symfony2 tests - http://www.ricardclau.com/2013/03/apc-vs-zend-optimizer-benchmarks-with-symfony2/ ).
I use it for my zf2 + doctrine2 + zfcUser application. Memcached is used for doctrine2 purposes, it gives only about 5% performance increase. So with ZendOp+ I got 6x increase (0.2 -> 0.03s) for simple pages and 3x increase (0.2 - 0.06) for complex pages with a lot of forms, entities, views. If I use classmap generator, I will update the answer.
Another issue is to use nginx + php-fpm rather than apache2+module. It saves server resources.
http://hounddog.github.io/blog/performance-in-zend-framework-2/
http://www.masterzendframework.com/reviews/maximising-zend-framework-2-performance-phpuk14/
http://stackoverflow.com/questions/19098718/preventing-crf-attacks-on-ajax-requests-in-asp-net-web-forms http://stackoverflow.com/questions/6287903/how-to-properly-add-csrf-token-using-php http://pt.wikihow.com/Prevenir-Ataques-CSRF-em-PHP http://phpsp.org.br/protegendo-seu-sistema-contra-ataques-csrf/
JSON Web Token Authentication for Slim