Best laravel framework open-source packages.

Phalcon4 template

Modern and Ready Use Phalcon Template based on Laravel technics and respected DDD pattern rules. Powered by Docker, PHP 7.4.5, Phalcon v4, Redis v6, PostgresSQL 12, NGinx 1.17.10, PHPUnit, Composer Autoloading system and etc.
Updated 2 years ago

Image of social preview

🔥 Use template functionality and start to coding easly

  • Use this template to create your new public or private repository from HERE or green button on top right side above. It will ready in a few seconds:

image

🔥 Super Fast start guide

  • clone .env.example to .env
  • set DB name, DB user and DB password on .env
  • clone config.example.yml to config.yml
  • configure config.yml with your credentials
  • run docker-compose up -d
  • wait docker to complete build process ... it will take 10 or 15 minutes max
  • run docker-compose exec app php composer.phar install to install vendors
  • run docker-compose exec app php composer.phar dump to restart autoloader
  • go to http://localhost:34423/ and enjoy the life :D
  • feel free to Contribute, open Pull requests and add your bugs on Issues

🔥 Important Rules

  • Don't use the real DB for Testing, instead use SqLite adapter for Unit Testing
  • Don't expose secrets on source code, instead use config.yml.
  • Don't forget to clone the new config variables to example.config.yml variable.
  • Don't forget to create migrations for the new tables.
  • Don't directly create Models, Controllers, Modules for application, instead use CLI commands to generate from stubs.

🔥 TODO

  • ElasticSearch Client
  • Middleware
  • Migrations
  • Storage
  • fatal error catching to sentry
  • Stubs for CLI creation
  • Add some common tasks (clear cache, clear session and etc.)

🔥 System Requirements

  • Docker installed on your machine (Docker desktop or / Docker for linux)
  • Min: 1GB ram

🔥 Helper definitions

  • app() returns current application instance.
  • app()->getRootPath() returns the full base path of root directory (for ex: /home/api/www/).
  • app()->getRootPath('routes') returns the full base path of given directory (for ex: /home/api/www/routes).
  • app()->environment() returns current application environment (defined in config.yml).
  • app()->environment('test-env'') returns TRUE if given environment (test-env) is equals to application environment.
  • di() returns default DI instance
  • apcu() returns default APCU Cache instance
  • redis() returns default REDIS Cache instance
  • logger() writes given log to daily log file located at logs folder
    • logger()->error('...')
    • logger()->debug('...')
    • ...
  • config() returns all configurations defined on config.yml
  • config('env') returns specified key from a config. Another nested usage:
    • config('dirs.tmp) returns tmp directory for application
  • encrypt() returns safe encrypted version of given text with the key specified on config.yml. This will work only used key. You can lose access to raw data if you change app key in the config.yml. Usage:
    • encrypt('test') returns 1A49a9cig2tYX+949MKe0RECF2JyI0AHoBKnRvyleIQ=
  • decrypt() returns safe decrypted version of given text with the key specified on config.yml. This will work only used key. You can lose access to raw data if you change app key in the config.yml. Usage:
    • decrypt('1A49a9cig2tYX+949MKe0RECF2JyI0AHoBKnRvyleIQ=') returns test
  • session() returns session instance. Usage:
    • session()->set('test-key','test-value) void method. Don't wait something.
    • session()->get('test-key') returns test
    • session()->has('test-key') returns TRUE|FALSE related to existence of key test-key

🔥 Tricks

  • How to define table name of Model
    • By default, table name will be underscored version of Model name. For example, if you create model with name News table name will be news. If you create with name NewsNotes, table name will be news_notes.
    • If you want to add custom table name, just add protected ?string $table = 'example_table'; property to model class. ExampleModels added for this purpose.
  • How to fail if Model can't find searched row ?
    • We have implemented findOrFail method from Laravel architecture. Usage: ExampleModel::findOrFail(2), this will search for row with ID 2 and will fail if not exists on DB.
  • How to disable exception reporting to Sentry?
    • Open specific exception class and override public bool $sentry = FALSE; property
  • How to regenerate loaded class (sometimes it happens that some classes not getting recognized)?
    • php composer.phar dump
  • How to update composer packages? (recommended doing it weakly)?
    • php composer.phar update
  • How to install only production required packages? (don't recommended installing development packages on production)?
    • php composer.phar update --no-dev
  • How to run all PHPUnit tests?
    • vendor/bin/phpunit ./tests
  • How to run specific PHPUnit test?
    • vendor/bin/phpunit ./tests/ExampleTest --filter=test_example_action_response
  • How to run task with specific action?
    • php task \\App\\Example\\Task\\Example example

🔥 Example responses

  • Example 404 response JSON:
{
   "status": "exception",
   "code": 404,
   "message": "This request isn't handled by our resources.",
   "data": {},
   "rat": "2020-06-01T19:10:38+00:00",
   "trace": null
}
  • Example 200 response JSON:
{
    "status": "success",
    "code": 200,
    "message": "Everything working!",
    "data": {},
    "rat": "2020-06-01T19:43:53+00:00",
    "trace": null
}