Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bootstrapping and configuration in 3.0 #860

Merged
merged 42 commits into from Sep 21, 2012

Conversation

markstory
Copy link
Member

Following the discussion on cakephp-core I've implemented most of the changes discussed but I'll reiterate some of the most important changes again.

  • Cache, Log, and Email now all use Configure for configuration data. The various config() methods now emit errors, and the EmailConfig class has been removed.
  • I have not updated ConnectionManager, but there is a connections.php with a possible approach. I figure ConnectionManager will be updated as the model layer is re-worked.
  • Support for PHP's include_path has been temporarily removed, but will come back when I start work on integrating composer.
  • The bootstrapping of a CakePHP application has in my opinion been greatly simplified and most voodoo has been removed. Declaration of all path related constants has been moved to App/Config as it simplifies overriding those constants.
  • Console bootstrapping is now the same as web request bootstrapping which is a nice bonus.

Changes to Log and Cache

Both Cache and Log now feature an engine() method. This method can be used to directly inject dependencies and fetch instances. It also allows Cache to lazily load all engines, which could help performance. Similarly, Log lazy loads loggers upon the first call to write().

  • Log has had all the backwards compatibility feature removed as they were deprecated.

Exceptions removed

A number of exceptions with very few uses have been removed. There was no real benefit from having additional marker exception classes.

Edit Finished the description, I accidentally submitted too soon.

Remove core.php it is no longer required.
Add default config files for email and datasources.
Both config() methods are still not implemented.
Squash and revert a number of changes as they were just a bad idea.
Complete transition to using Configure for configuration.
* Update App/Config/cache.php to use Configure.
* Remove Cache::isInitialized() as it is no longer required.
* Add Cache::engine() this method allows lazy construction of cache
  engines.  It also encapsulates checks for Cache.disable.
* Update methods to use new methods.
* Add several tests for set() as it had fairly sparse coverage and some
  common cases werw missing.
* Missing cache configurations now trigger warnings about their absencse
  instead of silently returning false.  While this may be too noisy in
  some situations, having silent failures makes debugging difficult as
  you are entirely unaware that no work isn't being done.
This will help people upgrade eaiser than just removing the method.
This can be helpful when doing testing, or if you have a CacheEngine
that requires setup that is not feasible with the standard process.
Logging will soon be configured through Configure like other
configurable parts of CakePHP.
Remove many the legacy features like:

* Autoconfiguration of a file logger. You should remember to configure
  a logger if you want logging.
* Ability to add/modify logging levels. There is really no reason for
  this functionality to exist. It was primarily a BC work around for
  people logging random messages and wanting them to show up in
  different log files. Logging scopes accomplish this in a far more
  extensible manner.
* Removed the ability to log to undefined log levels. write() now
  returns false when you've logged to nothing.
* When using defined levels/scopes both the scope & level of a message
  must intersect with the loggers scope/message or the message will be
  ignored. This makes logging more strict, but more predicatable.
Both these exception classes have very few callers and really don't
offer the end user any additional information beyond a type.
* With only one thrower this exception was not worth its weight.
  Replace with the base CakePHP exception.
* Update + fix tests for Cake\Model\Datasource\Session.
@jrbasso
Copy link
Member

jrbasso commented Sep 20, 2012

Awesome! 👍

@zoghal
Copy link
Contributor

zoghal commented Sep 20, 2012

👍

*/
Configure::write('Acl', [
'database' => 'default',
'classname', 'DbAcl',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be 'className' => 'DbAcl' ?

@bar
Copy link
Contributor

bar commented Sep 20, 2012

👍 too

/**
* Once configured, set the error/exception handlers to PHP's default handlers.
*/
Configure::setErrorHandlers();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this function into the App class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why not.

@lorenzo
Copy link
Member

lorenzo commented Sep 20, 2012

Nice work mark! One thing I was thinking is, can we still keep the dot notation for plugins? I find it boring having to specify the full class name for a class I want true in an engine. It is obviously cool and powerful being able to do so, but I don't expect everyone to remember exactly what the path is for each class

@jrbasso
Copy link
Member

jrbasso commented Sep 20, 2012

@lorenzo Yes. All classes that load others classes support dot notation or "partial" name. Having the full class name is just a faster way.

@lorenzo
Copy link
Member

lorenzo commented Sep 20, 2012

Oh, cool :)

Its no longer used and often a lie when path bootstrapping is used.
It works again.
@markstory
Copy link
Member Author

I think I've addressed most of the comments. If there isn't anything else, I'll merge this in and start working on the next bit. Which will probably be restoring AllTests with incomplete test markers, as right now the test suite isn't overly usable.

lorenzo added a commit that referenced this pull request Sep 21, 2012
Update bootstrapping and configuration in 3.0
@lorenzo lorenzo merged commit 37047c6 into cakephp:3.0 Sep 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants