So I have a vhost config in my puppet manifest file
apache::vhost { 'site.dev':
port => '80',
docroot => '/home/vagrant/projects/Personal/php/site/public',
serveradmin => 'admin#admin.dev',
options => ['Indexes','FollowSymLinks','MultiViews'],
setenv => ["APP_ENV dev"],
override => ['All'],
}
Now I want to add these options
EnableSendfile Off
EnableMMAP Off
I googled and found that concat::fragment might just be what I need, so I tried the following:
concat::fragment { "site.dev-static":
target => '25-site.dev.conf',
order => '01',
content => '
EnableSendfile Off
EnableMMAP Off
',
}
NOTE
In the target I have also tried with the full path: /etc/apache2/sites-available/25-site.dev.conf (with same results)
When I do vagrant provision I get this:
-- snip --
==> acs_dev: Warning: Scope(Concat::Fragment[Listen 80]): The $ensure parameter to concat::fragment is deprecated and has no effect.
-- snip --
I assume this worked fine but when I go to the vhos file at /etc/apache2/sites-available/25-site.dev.conf the EnableSendfile and EnableMMAP are not there.
I am using version 2.0.0 of puppetlabs concat module.
What do I need to do to make this work??
UPDATE
Apparently I could have just used
custom_fragment
In the vhost code. Don't know why this doesn't appear first in the module documentation.
You can add custom fragments in the vhost code like so:
apache::vhost { 'foo':
port => '80',
ip => '127.0.0.1',
add_listen => false,
proxy_pass => [
{
'path' => '/',
'url' => "http://127.0.0.1:8080",
'reverse_urls' => "http://127.0.0.1:8080",
},
],
docroot => '/var/www/html',
custom_fragment => '# Fragment content',
}
I also find that using the template function makes it easier to manage the content if it's a long fragment:
custom_fragment => template('apache_profile/etc/httpd/apache_custom_fragment.erb'),
The custom_fragment parameter is documented in the README.md
Related
Upgraded CakePHP from 3.5 -> 3.6 -> 3.7. The error message, Property _transportConfig does not exist, is displayed as soon as the application starts in the browser.
Email Transport config in app.php
'EmailTransport' => [
'default' => [
'className' => 'Smtp',
'host' => 'smtp.gmail.com',
'port' => 587,
'username' => '*******#gmail.com',
'password' => '********************',
'log' => true,
'tls' => true
],
],
I've found some information in the migration guide, here is a solution that may work;
First, you need to add this to your bootstrap file
use Cake\Mailer\TransportFactory;
then replace
Email::setConfigTransport(Configure::consume('EmailTransport'));
by
TransportFactory::setConfig(Configure::consume('EmailTransport'));
finally you might consider updating the debugger via composer :
λ composer require --update-with-dependencies "cakephp/debug_kit"
Might not be the best way to, but it worked for me!
DebugKit Toolbar do not show at the top-right of my localhost/thegioididong page.
Try:
bin/cake plugin assets symlink
to load debugkit assets.
SOLVED! I do these thing:
1: check the debug status at the top of config\app.php.
`'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),`
2: add to the end of config\bootstrap.php these codes:
`if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}`
3: create debug_kit table in mysql database - leave it empty database (localhost/phpmyadmin - in my case), then add:
'debug_kit' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Mysql',
'persistent' => false,
'host' => 'localhost',
'username' => 'root',
'password' => 'root1234',
'database' => 'debug_kit', //leave it empty - without tables
'encoding' => 'utf8',
'timezone' => 'UTC',
'flags' => [],
'cacheMetadata' => true,
'log' => false,
'quoteIdentifiers' => false,
'url' => env('DATABASE_URL', null),
],
into config\app.php following this structure:
'Datasources' => [
'default' => [
//default database config here
],
'debug_kit' => [
//debug_kit database config as above
],
'test' => [
//test database config here
],
],
Thanks a lot. I'm sory for my English!
in my case cake 3.5 this lines of code work
if (Configure::read('debug')) {
Configure::write('DebugKit', ['forceEnable' => true]);
Plugin::load('DebugKit', ['bootstrap' => true]);
}
add this line at the end of bootstrap.php
Do you have this in your bootstrap.php file?
if (Configure::read('debug')) {
Plugin::load('DebugKit', ['bootstrap' => true]);
}
enabled sqlite, for linux mint
nano /etc/php/7.2/apache2/php.ini
uncomment
extension=sqlite3
restart apache
service service apache2 restart
For CakePHP 3.x:
Check if "debug" is set to true. You may add debug('test'); somewhere in your app and check if you see the word "test" in your website's code at the beginning.
Check that debugkit plugin is loaded by adding debug(Plugin::loaded('DebugKit')); at the end of bootstrap.php. This should echo "true".
Add Configure::write('DebugKit', ['forceEnable' => true]); before you load DebugKit.
Add your development TLD to the "safeTld" property. (thanks #mark)
// Allow e.g. http://foo.bar.dev or http://my-shop.local domains locally
Configure::write('DebugKit.safeTld', ['dev', 'local', 'example']);
Copy or symlink asset plugins running bin/cake plugin assets symlink (use copy on windows)
Docs here.
Make sure you have sqlite extension installed. If you're using Laragon, enable Sqlite extensions in Menu > PHP > Extensions (this is what fixed my issue).
I'm trying to write tests for an action that sends an email, using get() / posts() methods provided by the IntegrationTestCase class.
The code is something like this:
$this->getMailer('User')
->set('someVarName', 'someVarValue)
->send('forgotPassword', [$user]);
Normally this code works.
But by testing, I get this error:
1) MeCms\Test\TestCase\Controller\UsersControllerTest::testForgotPassword
BadMethodCallException: Cannot send email, transport was not defined. Did you call transport() or define a transport in the set profile?
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/Mailer/Email.php:2049
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/Mailer/Mailer.php:252
/home/mirko/Libs/Plugins/MeCms/src/Controller/UsersController.php:213
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/Controller/Controller.php:440
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php:119
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php:93
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/Routing/Dispatcher.php:60
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/TestSuite/LegacyRequestDispatcher.php:61
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/TestSuite/IntegrationTestCase.php:426
/home/mirko/Libs/Plugins/MeCms/vendor/cakephp/cakephp/src/TestSuite/IntegrationTestCase.php:360
/home/mirko/Libs/Plugins/MeCms/tests/TestCase/Controller/UsersControllerTest.php:345
I've been looking a bit, but I did not understand how to set up a transport only for tests.
Thanks.
I didn’t came across such requirement, but the following should work.
In your /tests/bootstrap.php define a constant, so we can tell if we are in a testing environment:
define('_TEST', true);
// important: define above requiring the /config/bootstrap.php
require dirname(__DIR__) . '/config/bootstrap.php';
In /config/bootstrap.php check against the constant after the default app config file is loaded:
Configure::load('app', 'default', false);
// load an additional config file `/config/app_testing.php` in testing environment
if (defined('_TEST') && _TEST === true) {
Configure::load('app_tests');
}
Finally create the config file /config/app_tests.php for testing and overwrite some of the default config values:
<?php
return [
'Email' => [
'default' => [
'transport' => 'gmail',
'log' => true
]
],
'EmailTransport' => [
'gmail' => [
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'GoogleMailUserName',
'password' => 'GoogleMailPassword',
'className' => 'Smtp'
]
]
];
I have come across and issue that I need help with. I cannot figure out why this is happening.
I am creating a component in CakePHP that intercepts the data being passed to /users/login and depending on the parameter, it acts on it. However, the issue is that, when that data gets there, it is empty. To also note, is that it worked good on remote machines as well as local. The issue started happening when I used Composer to upload this plugin into another site. I wonder if the issue is because Composer installs the plugin under the vendor directory.
This is my code inside the component's startup method
public function initialize(array $config)
{
// ....
$this->Controller = $this->_registry->getController();
// ...
}
public function startup(Event $event)
{
// Here I try to get the [test] parameter that is pass in url
// http://www.domain.com/users/login?test=testing
$test = $this->Controller->request->query('test');
}
If I attempt to print the controller request inside the startup(Event $event) with debug($this->Controller->request); I get the following array:
object(Cake\Network\Request) {
params => [
'plugin' => null,
'controller' => 'Users',
'action' => 'login',
'_ext' => null,
'pass' => [],
'isAjax' => false
]
data => []
query => []
url => 'users/login'
base => ''
webroot => '/'
here => '/users/login'
trustProxy => false
[protected] _environment => [
'SCRIPT_FILENAME' => '/var/www/domain.com/website/webroot/index.php',
'SCRIPT_NAME' => '/index.php',
'REQUEST_URI' => '/users/login?test=testing',
'DOCUMENT_URI' => '/index.php',
The REQUEST_URI shows clearly that test is being passed.
What could be causing CakePHP not to take in the test parameter when it was installed using Composer? Why is params['pass'] => [], data => [] and query => [] empty?
After hours of trying to figure this out, it had to take my 8-year old daughter to point me out in the right direction. A simple, but time-wasting, head-scratching mistake that was causing all the issues. The issue was located inside my NGINX configuration file.
I had the following:
location / {
try_files $uri $uri/ /index.php$args;
}
but I should have had the following:
location / {
try_files $uri $uri/ /index.php?$args;
}
Because I had ommitted the ? after index.php, NGINX was simply not taking any parameters that were passed in the url.
Lesson learned!
I'm trying to provision a CentOS box using Vagrant and Chef Solo. I've specified some attributes I would like the apache2 cookbook to use but it does not appear to be using them.
Here's what I've added in my Vagrantfile:
chef.json.merge!(
'apache2' => {
'user' => 'testuser',
'group' => 'testgroup',
'dir' => '/custom',
'log_dir' => '/custom/logs/http',
'default_site_enabled' => false
}
)
chef.add_recipe "apache2"
Yet, after running vagrant up the apache cookbook has ignored all of the attributes I've specified. I've tried using both apache and apache2 as the key.
Am I missing something simple? Thanks!
This should merge the attributes into the node.
chef.json = {
'apache2' => {
'user' => 'testuser',
'group' => 'testgroup',
'dir' => '/custom',
'log_dir' => '/custom/logs/http',
'default_site_enabled' => false
}
}
And this is how you would access it.
node['apache2']['user'] # => testuser