GithubHelp home page GithubHelp logo

odan / slim4-skeleton Goto Github PK

View Code? Open in Web Editor NEW
423.0 29.0 80.0 5.25 MB

A Slim 4 Skeleton

Home Page: https://odan.github.io/slim4-skeleton/

License: MIT License

PHP 100.00%
php slim slim4 slim-4 skeleton slim-framework php8

slim4-skeleton's People

Contributors

antoninom90 avatar benycode avatar cdvrooman avatar dependabot-preview[bot] avatar dependabot[bot] avatar marchagen avatar odan avatar owis avatar pavog avatar ph-7 avatar raduungurean avatar tertek avatar ybelenko avatar ziauddin 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

slim4-skeleton's Issues

Docker mysql connection

Hello
This I don't think is a bug but I need help

I try to connect to a mysql server on another machine on the network, I change all the configuration files that I have found, but it always takes the address of the docker host.

Any help is appreciated

Captura de Pantalla 2021-07-05 a la(s) 13 32 03

Captura de Pantalla 2021-07-05 a la(s) 13 31 48

Silent of absent Twig debug option

Hi,

I am facing a weird behavior of twig while loading an array of items. Vars A, B, C, E, F load correctly but not D and G.
When trying to add the twig debug extension in order to double check if there is a template issue or override, I realized that the integration of this extension is not functional.

Is there any compatibility issue between the slim4 skeleton and the twig-view v3?

I tried to enable the debug mode setting debug = true (also from the env.php).
Tried also to add the DebugExtension in the container.php.

I am stuck ((

new project

Hi, thanks for you job..
I'd like to start my project form your job but i don't understand if i've to start from this skeleton or from tutorial..

Thanks for help

ps. Have time to help me for pay ?

composer migration:migrate: There are no commands defined in the "migration" namespace

I'm having an issue installing via composer on my CentOS 7...

On the last step of "Step 4: Configuration", when I run
composer migration:migrate
I get an error:
"[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "migration" namespace."

Thanks!
-Joe

Edit: I just noticed I'm using PHP version 7.2.34, where in your docs you say minimum 7.3... Could this be the issue?

Authorization 401

Hi friend, thank you for this framework.

I got a issue con the authorization (JWT), always stay in status 401, but I don't know for what.
The API generate TOKEN, but is false in this line:

` public function validateToken(string $accessToken): bool
{
$token = $this->createParsedToken($accessToken);

    //This is my error false----------------------------------------------------------
    if (!$token->verify($this->signer, $this->publicKey)) {
        // Token signature is not valid
        return false;
    }

    // Check whether the token has not expired
    $data = new ValidationData();
    $data->setCurrentTime(Chronos::now()->getTimestamp());
    $data->setIssuer($token->getClaim('iss'));
    $data->setId($token->getClaim('jti'));

    return $token->validate($data);
}`

What is your recommend? Thank u friend.

Questions regarding JWT with OAuth2

Hi @odan, how are you?

I implemented JWT with OAuth2 as your ebook taught (page 264). However, in my API there will be 3 types of users:
1 - Customers
2 - Members
3 - Administrators

And everyone will be able to access every route I designate. Routes 1 and 2 can be different, but 3 can access all routes. The username and password of each is in 3 different tables. My question is:

1 - Using best practices, can I use the same route (with the same Action and Domain), but passing the type_user variable to authenticate and validate according to the user?
$app->post('/tokens/{type_user:[0-9]+}', \App\Action\Auth\TokenCreateAction::class);

2 - Should I create 3 different JwtAuthMiddleware for each type of user? Or is there any way to add a Middleware to the route by passing a parameter to the Middleware?

3 - I know that JWT is an authentication protocol, not an authorization protocol. Is it feasible to encrypt the user type in the JWT token? Or should I use some feature that I still don't know about Auth 2?

4 - Can I require that all my routes also require basic HTTP authentication to make sure the requests are coming from my Android application?

Thanks in advance!

phpunit testing - The class is not instantiable

Hi, i'm having the current issue when running test case:

DI\Definition\Exception\InvalidDefinition : Entry "Psr\Http\Message\ServerRequestFactoryInterface" cannot be resolved: the class is not instantiable

Full definition:

Object (
    class = #NOT INSTANTIABLE# Psr\Http\Message\ServerRequestFactoryInterface
    lazy = false
)

the code is:

use App\Test\Traits\AppTestTrait;
use Cake\Chronos\Chronos;
use Fig\Http\Message\StatusCodeInterface;
use PHPUnit\Framework\TestCase;
use Selective\TestTrait\Traits\DatabaseTestTrait;

class MyCodeCreateActionTest extends TestCase {
    use AppTestTrait;
    use DatabaseTestTrait;

    public function testCreateDemo(): void {
        Chronos::setTestNow('2021-06-19 00:00:00');
        $request = $this->createJsonRequest(
            'POST',
            '/api/destination',
            [
                'field'    => 1,
                'field2'   =>1,
                'field3' => 10,
            ]
        );
        $response = $this->app->handle($request);

        // Check Response
        $this->assertSame(StatusCodeInterface::STATUS_CREATED, $response->getStatusCode());
        $this->assertJsonContentType($response);
        $this->assertJsonData(['status'=>'success'], $response);
    }
}

Any idea on how to solve it ?

NoSQL database testing

I don't know if my question is going to make sense but I am using NoSQL(Firebase). How would you handle testing in this case?? I would also appreciate if you would share some ideas on how to use/integrate NoSQL databases with this project. Thank you!

Safari cannot open the page

Cannot send request via Guzzle in home controller.
It's weird, but when I add line var_dump($learners); I can see rendered response.
Without var_dump page doesn't renders at all.

< HTTP/1.1 200 OK
< Date: Wed, 02 Sep 2020 10:53:40 GMT
< Server: Apache/2.4.34 (Unix) PHP/7.4.6
< X-Powered-By: PHP/7.4.6
< Cache-Control: max-age=0, private, must-revalidate
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8


* Received 1783 B chunk
* Illegal or missing hexadecimal sequence in chunked-encoding
* stopped the pause stream!
* Closing connection 20
<?php

namespace App\Action\Home;

use App\Responder\Responder;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use GuzzleHttp\Client;

/**
 * Action.
 */
final class HomeAction
{
    /**
     * @var Responder
     */
    private $responder;

    /**
     * The constructor.
     *
     * @param Responder $responder The responder
     */
    public function __construct(Responder $responder)
    {
        $this->responder = $responder;
    }

    /**
     * Action.
     *
     * @param ServerRequestInterface $request The request
     * @param ResponseInterface $response The response
     *
     * @return ResponseInterface The response
     */
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface
    {
        $client = new Client();
        $learnersUrl = 'http://apitest.test/api/learners';// localhost
        $response = $client->request('GET', $learnersUrl);
        $learners = json_decode((string) $response->getBody(), true);
        // var_dump($learners);
        return $this->responder->render($response, 'home/home.twig', [
            'now' => date('d.m.Y H:i:s'),
        ]);
    }
}

Offset not working in UserFinderRepository.php

$offset = min($params['offset'] ?? 0, 0);
I think this line return always 0 If I set positive integer value in the $param['offset']. So I fixing it in my repository function and just pointed in here as a reminder its not working :-).

I really like this repository and its really helpful to understood slim and use it for my current api development project.
Really appreciate.
Ziauddin

getParsedBody

Hi

i have a middleware
`<?php

namespace App\Middleware;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Slim\Views\Twig;
use Symfony\Component\HttpFoundation\Session\Session;

final class OldInputMiddleware implements MiddlewareInterface
{

private Twig $view;

private Session $session;
/**
 * @param $request
 * @param $response
 * @param $next
 * @return mixed
 */
public function __construct(Session $session,Twig $view)
{
    $this->session = $session;
    $this->view= $view;
}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{

    $tmp=$request->getParsedBody();
     var_dump($tmp);

    return $handler->handle($request);
}

}`

when i submit a form POST , the dump is empty , the getMethod is "GET"

`<?php

use App\Middleware\OldInputMiddleware;
use App\Middleware\SessionMiddleware;
use App\Middleware\UrlGeneratorMiddleware;
use App\Middleware\ValidationErrorsMiddleware;
use Selective\BasePath\BasePathMiddleware;
use Selective\Validation\Middleware\ValidationExceptionMiddleware;
use Slim\App;
use Slim\Csrf\Guard;
use Slim\Middleware\ErrorMiddleware;
use Slim\Views\TwigMiddleware;

return function (App $app) {

$app->add(ValidationExceptionMiddleware::class);
$app->add(Guard::class);
$app->add(UrlGeneratorMiddleware::class);

$app->addRoutingMiddleware();

$app->add(TwigMiddleware::class);
$app->add(OldInputMiddleware::class); // EMPTY getParsedBody
$app->add(ValidationErrorsMiddleware::class);
$app->add(SessionMiddleware::class);
$app->add(BasePathMiddleware::class);
$app->addBodyParsingMiddleware();
$app->add(ErrorMiddleware::class);

};`

any idea ?

Real time notification

Hi,

This is not an issue, but a question. What are the best solution to implement real time notification in a notification bar to integrate in slim4-skeleton. I start to read some information in the web to get a possible solution and i find multiple references to pusher service, but to be honest, I don't want to have dependencies with a pay solution. I also find references for a Ratchet php websocket solution that seems promising. My conclusion for now, is for performance issues, the solution must be a websocket solution.

The purpose here it's for example, someone fill a contact form in the website, and the person that are in the backoffice, receive a notification (a pulsing icon or anything else) stating that there is a new request for information.

Thanks!
Nelson Matias

Twig + Mailer Integration Issue

Hey @odan

I went though your Tutorial, the Twig implementation and the Mailer Implementation.
Would like to thank you for these awesome tutorials.

So good so far, but when I tried to use Twig inside emails, it simply doenst work. I was following the official documentation in Mailer, but I get an error:
Type: Symfony\Component\Mime\Exception\LogicException
Code: 0
Message: A message must have a text or an HTML part or attachments.
File: /vendor/symfony/mime/Email.php
Line: 405

I found a reference in this github:
symfony/symfony#35990

If this is easy to solve, I guess it would be nice to be in your tutorials

I need tips on the ADR pattern for programming best practices

Hi Odan, I want to thank you immensely for this SLIM 4 skeleton that you provided to the community. However, I have a beginner's doubt:

By the ADR development pattern, let's assume I have a domain called Categories and another one called Subcategories with their respective Actions (following your SLIM 4 skeleton pattern). The Categories action returns the categories and the Subcategories action returns the subcategories for their respective routes.

However, I need a route that returns the subcategories with categories Following good programming practices, can I create an Action SubcategoriesWithCategorie (without any domain) and through this Action access the Categories domain and the Subcategories domain?

Markdown_to_Html Email implementation

Hello @odan,

I have an Issue implementing Markdown_to_Html Email extension

I have used this tutorial: https://twig.symfony.com/doc/3.x/filters/html_to_markdown.html that I will paste the code suggested below:

Then, use the twig/extra-bundle on Symfony projects or add the extension explicitly on the Twig environment:

use Twig\Extra\Markdown\MarkdownExtension;

$twig = new \Twig\Environment(...);
$twig->addExtension(new MarkdownExtension());

If you are not using Symfony, you must also register the extension runtime:

use Twig\Extra\Markdown\DefaultMarkdown;
use Twig\Extra\Markdown\MarkdownRuntime;
use Twig\RuntimeLoader\RuntimeLoaderInterface;

$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
public function load($class) {
if (MarkdownRuntime::class === $class) {
return new MarkdownRuntime(new DefaultMarkdown());
}
}
});

I added the extension in container.php, but wasn't sure if there is the place to add the RuntimeLoader, or if it is really necessary or a different approach is needed.

As far as I can tell it is being executed, but nothing changes the resulting email.

By the way, Im using the league/commonmark library as recommended here (https://symfony.com/doc/current/mailer.html#rendering-markdown-content)

Sorry to bother you with that

QueryParams as optional in

Hi Odan! How are you? I want to implement in all GETs of my API the parameters Limit and Offset as optional. I have some questions regarding QueryParams:

  1. Using good programming practices, I can implement Query Params in URI
    $app->get('/users[/{array}]', \App\Action\User\UserFindAction::class), for example,
    or the more correct way is to create another URI with another action (UserSearchAction, for example): $app->get('/users/search[/{array}]', \App\Action\User\UserFindAction::class) .
  2. The validation of this array of parameters is done only in the Service?

Do you have any complete examples on your blog or in the book that I can follow of QueryParams and also a route that uses the PATCH method? I really appreciate your help, I'm a beginner programmer, but I want to do everything as correctly as possible.

PS: I bought your book and found it sensational, it surprised the expectations a lot. I looked for copper, but I found gold. Are there any communication channels (Telegram, Discord) for book buyers?

Is slim4-skeleton fully compatible with cakephp/localized?

Hi @odan Odan, how are you? Added cakephp/localized library to Validation Services on my Domain. Initially, it was not compatible with CakePHP 4.X. I contacted the cakephp/localized developer ( cakephp/localized#215 ) reporting these compatibility issues, and just yesterday this library became compatible with CakePHP 4.X. However, when installing cakephp/localized and its dependencies via Composer, the following error occurs:

The \"_cake_core_\" cache configuration does not exist. in C:\\xampp\\htdocs\\setorconvenios\\vendor\\cakephp\\cakephp\\src\\Cache\\Cache.php

Is this CakePHP cache configuration done somewhere in the slim4-skeleton?

Thanks in advanced.

composer migrate not found

The documentation states to execute "composer migration:migrate" but It seems not working anymore:

image

image

It does work if you execute "composer phoenix migrate" tho.

Latest version of this repo, cloned today with the command "composer create-project odan/slim4-skeleton my-app"

  • Greetings

Migration Error

Hello,

I am still very new to slim and to your project. I have just created a new test project following the instructions in the documentation. When I get to composer migrate it errors with this

> phinx migrate -c config/phinx.php --ansi
Phinx by CakePHP - https://phinx.org.

using config file ./config/phinx.php

In Driver.php line 92:
                                                    
  SQLSTATE[HY000] [2002] No such file or directory  
                                                    

migrate [-c|--configuration CONFIGURATION] [-p|--parser PARSER] [-e|--environment ENVIRONMENT] [-t|--target TARGET] [-d|--date DATE] [-x|--dry-run] [--fake]

Script phinx migrate -c config/phinx.php --ansi handling the migrate event returned with error code 255

I guessed that I missed something so I started over and retraced the steps. It errors with the same error, each time.

Could you help me to figure out what I am missing or doing wrong?

Thanks

routes with parameters don;t work...

PHP: 7.4
I've just created a new project using the command

composer create-project odan/slim4-skeleton my-app

However when I run it

PHP -S localhost:8080 -t public

The issue a GET against http://localhost:8080/users/1234 or http://localhost:8080/hello/world

I get a route failure

404 Not Found - Error details: [404] Not found. in C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php on line 93. Backtrace: #0 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php(59): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request)) #1 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(140): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #2 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\twig-view\src\TwigMiddleware.php(125): class@anonymous->handle(Object(Slim\Psr7\Request)) #3 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(188): Slim\Views\TwigMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #4 C:\Users\Mark\PhpstormProjects\clientservices\vendor\selective\basepath\src\BasePathMiddleware.php(52): class@anonymous->handle(Object(Slim\Psr7\Request)) #5 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(188): Selective\BasePath\BasePathMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #6 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\Middleware\ErrorMiddleware.php(107): class@anonymous->handle(Object(Slim\Psr7\Request)) #7 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(188): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #8 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\MiddlewareDispatcher.php(81): class@anonymous->handle(Object(Slim\Psr7\Request)) #9 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\App.php(215): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #10 C:\Users\Mark\PhpstormProjects\clientservices\vendor\slim\slim\Slim\App.php(199): Slim\App->handle(Object(Slim\Psr7\Request)) #11 C:\Users\Mark\PhpstormProjects\clientservices\public\index.php(3): Slim\App->run() #12 {main}

The issue seems to be any route with a named parameter...

vue.js integration

Thank you for this application. I want to add vue.js to this application. How can I do it?

Roadmap v.0.17

Roadmap

  • Remove all frontend specific dependencies (Twig, NPM, etc) and examples.
    This makes it possible to use this Slim-skeleton for pure APIs as well.
  • Add BasicAuth as simple API auth mechanism
  • Update tests
  • Update documentation

Ant build fails

Hi @odan. Check this please

composer create-project odan/slim4-skeleton my-app
composer build

C:\my-app>composer build
> ant build
Buildfile: C:\my-app\build.xml

build:
      [get] Getting: https://getcomposer.org/composer.phar
      [get] To: C:\my-app\build\composer.phar
     [exec] fatal: not a git repository (or any of the parent directories): .git

BUILD FAILED
C:\my-app\build.xml:73: exec returned: 128

Total time: 8 seconds
Script ant build handling the build event returned with error code 1

Way of communication

Is there a way of communication to speak/ask question about this skeleton?
I have some "generic" questions, but I don't want to abuse the issue system.

(Maybe by enabling the Discussions feature in this repos settings)

Change default language

Hi @odan,

I need to change the default language. I have created my new language and if I assign the new language to the user, it works correctly with de logged user. But if I go to config > defaults.php and modify the language in the parameter 'locale' with 'de_DE' or my new language, the language on the home page remains in English.

Should I do something else?

Thanks

odan/phinx-migrations-generator -> PHP 8.0.2

When trying to install latest slim4-skeleton with php 8.0.2 getting following error for dependent composer package. I am also using composer 2.0 to manually install all composer dependencies.

Problem 1
- odan/phinx-migrations-generator[5.0.0, ..., 5.3.2] require php ^7.2 -> your php version (8.0.2) does not satisfy that requirement.
- Root composer.json requires odan/phinx-migrations-generator ^5 -> satisfiable by odan/phinx-migrations-generator[5.0.0, ..., 5.3.2].

csrf

Hi

please, can you add csrf middleware on the skeleton ? I fail to implement it and think its a good exemple to understand Slim4 and ADR

thank you

I have some problem with UserAuth dependency on Class LoginSubmitAction

When I try to receive UserAuth dependency on LoginSubmitAction class constructor, returns error "DI\Definition\Exception\InvalidDefinition". It's like as the class is not injected as dependency

public function __construct(Responder $responder, Session $session, **UserAuth $auth**) { $this->responder = $responder; $this->session = $session; $this->auth = $auth; }
Any idea? Thank's

Click to Download option

Is this possible to add a link to download with storage directory with slim 4 and how?

Ex. "Download" and Link is: (myweb/storage/04/download.zip).

Unit Testing with Fixtures

Thank you for this amazing project once again. I am trying to figure out how to use fixtures(UserFixture class & UserCreatorRepositoryTest class) with unit testing and I am completely lost. I have tried using debug when testing and I am still unable to tell whether the fixtures are being used or not. I can't also tell where DatabaseTestTrait comes into play and how it's being used or when it is executed. If it is possible, I'd like to request that you please post a quick walk-through of how all these work/fit together.

Right now am faced with a situation where I run tests and they fail for situations where one test fails because of changes made by another test that precedes it e.g. If am testing a class that views a specific user and a test that deletes that specific user runs first or when creating a user and I have to update the last inserted id(in expected response) every time I run tests.

Also, more examples on this will be of huge help. Thanks, a lot!!

How to use the /src/Handler/DefaultErrorHandler.php

I'm looking into ways of outputting more information when a 404 happens, I'm using the following code at the moment

    $app->addBodyParsingMiddleware();
    $app->addRoutingMiddleware();

    // Error Middleware
    $loggerFactory = $app->getContainer()->get(\App\Factory\LoggerFactory::class);
    $logger = $loggerFactory->addFileHandler('error.log')->createInstance('error');

    $app->addErrorMiddleware(true, true, true, $logger);

So I'm wondering, the file in this repository, src/Handler/DefaultErrorHandler.php, how can I make sure that this one is used instead of the default in Slim? Thank you!

Edit Closed, this is clearly defined in the docs but for some reason I missed it

Validating JWT protected resource

First off, many thanks for your tutorials, they are very helpful. I've followed the JWT section in your eBook and all is well but how do I go from there to protect some resources with this token. For example, if I want to pull a user profile from a USER table, I need to make sure the token is not only valid but corresponds to this specific user. It seems logical to inspect the token to retrieve the 'uid' but where? When JwtAuthMdwr completes, if it is a valid token, control is passed to the routeAction... should I get the token and inspect for proper uid at this point ? If so, how ?

ORM for database

Hello. Your work is great and I used it in a quite big project, finding it very well organized and structured.
Working with it I struggled sometimes with the repository concept. There is a lot of code replication between different repositiories and lot of times I needed to go and change code in different files. Also CakePhp is not well documented (in the way you use it).
May I suggest to use ORM for database communication? It could be more practical and reduce code boilerplate.
I found this library http://propelorm.org/ that I think is awesome for different reasons:

  • Incredibly well documented
  • Easy to use
  • Migration and schema dump is included (probably better than using a different service for the migration)

Well this is just an opinion :) And I wanted to share my feedback about this project after using it.

One last thing: it would be nice to include in this repo some example of different scenarios and use cases (for example I used a react frontend and the backend only for rest api). It could be useful if someone needs to understand the "correct" way of using this (I can try to share some example and collaborate in this project if you want).

Nice work!

Forbidden

Hello Odan,

I am new to slim and this skeleton project. I tried to install this skeleton on my MacBook on a local Apache Web Server. Before I installed the skeleton I ensured that I could access php and html files from the server.

I put my skeleton under a /bp subdir.

Now, when I enter http://localhost/bp I get the errormessage: "Forbidden" from the server. Where can I start to look what went wrong with my installation?

Thank you!

PHP Session timeout

How do I expire a PHP session after 30 minutes for example? I try this to add this values in the config/defaults.php but it doesn't work:

// Session
$settings['session'] = [
'name' => 'webapp',
'cache_expire' => 0,
'gc_maxlifetime' => 3600,
'cookie_lifetime' => 604800
];

Thanks,
Nelson Matias

Settings file depends on superglobal $_ENV

// Testing and integration environment
if (isset($_ENV['APP_ENV'])) {
require __DIR__ . '/local.' . $_ENV['APP_ENV'] . '.php';
}

$_ENV might not always be populated, depending on php.ini directive variables_order and/or cli mode + os.

variables_order string

Sets the order of the EGPCS (Environment, Get, Post, Cookie, and Server) variable parsing. For example, if variables_order is set to "SP" then PHP will create the superglobals $_SERVER and $_POST, but not create $_ENV, $_GET, and $_COOKIE. Setting to "" means no superglobals will be set.

See: https://www.php.net/manual/en/ini.core.php#ini.variables-order

It seems function getenv() is to be the most solid way to get a value of environment variables.
See: https://www.php.net/manual/en/function.getenv

I think it's more fail-save to add the following to defaults.php:

// Environment settings
$settings['environment'] = $_GET['APP_ENV'] ?? getenv('APP_ENV');

and line 14 to 16 of settings.php to:

if ($settings['environment'] !== false) {
    require __DIR__ . '/local.' . $settings['environment'] . '.php';
}

You could also evaluate the return-value of getenv('APP_ENV') everywhere where needed, but imho that creates overhead.

Not a issue but asking for help

Hi Odan

This is not a issue but asking for help.

Maybe i should put it in Discussions but it is not enabled in this repository.

I'm trying to build a web application with an HTML interface by this slim skeleton, it is realy helpful to me.

Now i want to create a new table called user_profile to store the extra infomation for a user just like age,gender,address,phone nubmer,profile etc.

These fields will be shown in the samme page with username,role,email,enabled in the same page for view and update.

What am i wendering is how to structure the Domain layer.

Should i create a sub-folder named userProfile under folder Domain then create it's own Data,Repository and Server folders

or create UserProfileData,UserProfileRepository,UserProfileServices files under Domain\User\Data ,Repository and Service

or just merge the logic code into UserData ,UserRepository and UserService?

Is there any suggestions or best practice here?

Many thanks.

Twig assets

I did followed your tutorial twig-webpack-extension-setup with this skeleton which getting error 404. Do you have any idea what cause the problem?

image

phinx vs phoenix

Files schema.php and deploy.php use the term phinx.
Shouldn't this be phoenix?

Use for REST API only.

Sorry in advance if this question is not meant to be here. How would I use this skeleton to develop a REST API only while also ensuring a front-end dev can easily integrate their UI with this?I would like to avoid including npm/webpack related stuff, github workflow e.t.c. I'm learning how to use Slim framework for creating REST API and this is very new to me.

Flash Messages

I update my code with the changes done in the container (Reverted session handler. Fixed session starts by lazy loading the fl 8 August), but now, this code doesn't work anymore:

{% for label, messages in flashbag.all %}
{% for message in messages %}
....
{% endfor %}
{% endfor %}

but

{% for message in flashes('success') %}


{{ message|trans }}

{% endfor %}

work.

My question id with the first version, i can reduce the code to use with BootstrapNotify. I always spend some hours to resolve this issue but i don't find the solution yet.

Thanks.

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.