Sometimes, I use any of the following mentioned names to name the install/upgrade scripts in custom modules:
install-0.1.0.0.php
upgrade-0.1.0.0-0.1.1.0.php
upgrade-0.1.1.0-0.1.2.0.php
----------------------------
install-0.1.0.php
upgrade-0.1.0.0-0.1.1.php
upgrade-0.1.1-0.1.2.php
Is there a standard way to follow for this naming conventions for install/upgrade scripts?
Versioning follows some conventions/standards, here is the code snippet from Mage.php to give an idea how module versions can be decided. This is for Magento version 1.7.0.2
array(
'major' => '1',
'minor' => '7',
'revision' => '0',
'patch' => '2',
'stability' => '',
'number' => '',
);
As I know, there's no standard way and you can name your scripts and versions as you need( it uses php version_compare anyway).
Related
I'm new to ZF. I'm using wamp 3. I followed the instructions from the Zend Framework Documentation (https://framework.zend.com/manual/2.4/en/user-guide/database-and-models.html), installed ZendSkeletonApplication and everything worked fine until step 3 (routing and controllers) when I got the error:
"A 404 error occurred
Page not found.
The requested URL could not be matched by routing.
No Exception available".
I don't know what the problem is, since I copied everything from the tutorial on the site (so that I don't make any typo) and it still won't work.
Any suggestions what the problem might be?
module.config.php looks like this:
return array(
'controllers' => array(
'invokables' => array(
'Album\Controller\Album' => 'Album\Controller\AlbumController',
),
),
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
);
I did everything as they wrote, but when I go to "myvirtualhostname/album" it shows me the error above.
make sure you add this line (highlighted by comment) to the top of your public/index.php
<?php
use Zend\Mvc\Application;
use Zend\Stdlib\ArrayUtils; //<-- add this line
Note#1: you need to follow instructions of editing the index.php file for developing mode enabled, they just forgot to tell about using ArrayUtils in this tutorials.
Note#2 make sure to enable dev mod from the composer and dump autoload like this :
$ composer development-enable
and then:
[$ composer dump-autoload]
I believe you can specify the version you want to install with the initial composer command, something like this:
composer create-project -sdev zendframework/skeleton-application:^2.4 path/to/zf2-app
although you may be able to change the version on your existing skeleton app, it might be easier to run the above command in a different folder, and then copy over the files you've added or changed whilst following the tutorial.
And just to say again, unless you specifically need to learn ZF2.4, it would be better to stick with ZF3 (since that's the current version), and just follow the ZF3 tutorial instead. The differences between them are not that big.
I am cpan module which have prerequisite on other module. Is there any process to make sure the module can be installed only after the installation of the prerequisite module while
manual installation of the module.
perl MakeFile.pl
make
make test
make install
Yes. Use a standard build management module like
ExtUtils::MakeMaker or Module::Build, which have conventions to handle prerequisites.
For ExtUtils::MakeMaker, the convention is to pass prerequisite information in the PREREQ_PM argument to the WriteMakefile function. Here's what it might look like:
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'My::Module',
AUTHOR => 'Me',
VERSION_FROM => 'lib/My/Module.pm',
PREREQ_PM => {
'Some::Module' => 0.42, # need >=v0.42 of Some::Module
'Some::Other::Module' => 0, # but any version of Some::Other::Module is ok
}
dist => ... ,
clean => ... ,
...
);
Is there a way to obtain version info for a moodle site using only "teacher" level access? It seems as though this ability was removed in versions 1.9.7 and above. I'm trying to automate the process of uploading tests and having the version info would be rather handy.
In order to see the current version of moodle you just need to read this file:
http://yourmoodlesite/lib/upgrade.txt
Here's more information about it:
https://github.com/moodle/moodle/blob/MOODLE_29_STABLE/lib/upgrade.txt
Sorry, these instructions may seem somewhat obscure, but it's the only way I could find to get the version of Moodle with only "teacher" level access.
As a teacher, you should be able to create a backup of any of your courses (though this capability may have been removed in the Moodle you're using). Backups are just zip files, but instead have a .mbz extension. If you change this extension to .zip, you'll be able to extract the zip. With the zip extracted, open "moodle_backup.xml", in there you should find the "moodle_release" item somewhere near the top, giving you the version of Moodle used to create the backup.
Being a TA, I didn't want to mess around with backups which sounds weird but given my unique position, reasonable (to me).
On the implementation of moodle I use, with TA privilege, a link to moodle docs is present at the bottom of the page and if you open this link, it takes you to the moodle docs page with moodle_url/moodle_version/___.
Maybe this is peculiar to my system, but I believe it's a default setting thing.
The most dirty way to do so when no admin or file access, is doing differs from public files between versions. As example, index.php file can be 1024Kb lenght on v1.x and 1033Kb lenght on version 1.2.
Also, check for existance/non existance of a set of files is a common way (css, html, js, icon, etc)
I will edit this again if i find a specific solution.
First edit:
For versions 19 or above, you can check version direcly from readme.txt file at https://github.com/moodle/moodle/blob/MOODLE_19_STABLE/README.txt
If you don't even have an account on the instance, you may still be able to find out the version. Any authentication errors in the API will return an error message of the form:
[{
"error":true,
"exception":{
"message":"Course or activity not accessible.",
"errorcode":"requireloginerror",
"link":"https:\/\/moodle.example.com\/",
"moreinfourl":"http:\/\/docs.moodle.org\/36\/en\/error\/moodle\/requireloginerror"
}
}]
And the moreinfourl contains an approximate version number (in this case 3.6). For me, this page was requested when I visited the login page for the instance - a POST request to
https://moodle.example.com/lib/ajax/service.php?sesskey=JQrdIcgMn4&info=core_fetch_notifications
My helper function here:
https://gist.github.com/tigusigalpa/af051a9112512b1b0369572b5dbea2fd
function checkMoodleVersion($version, $checkfor = 'all', $compare = '<=') {
global $CFG;
$versions = [
'3.1' => [
'version' => '2016052300',
'release' => '3.1'
],
'3.2' => [
'version' => '2016120500',
'release' => '3.2'
],
'3.3' => [
'version' => '2017051500',
'release' => '3.3'
],
'3.4' => [
'version' => '2017111300',
'release' => '3.4'
],
'3.5' => [
'version' => '2018051700',
'release' => '3.5'
],
'3.6' => [
'version' => '2018120300',
'release' => '3.6'
]
];
switch ($checkfor) {
case 'all':
if (isset($versions[$version]['version'])) {
return version_compare($versions[$version]['version'], $CFG->version, $compare) &&
version_compare($version, $CFG->release, $compare);
}
break;
case 'version':
case 'release':
if (isset($versions[$version][$checkfor])) {
return version_compare($versions[$version][$checkfor], $CFG->$checkfor, $compare);
}
break;
}
return false;
}
Not by default as this could be used to harvest out of date moodle sites.
You could create a script to do this fairly easily, eg:
<?php
require_once('config.php');
echo 'Version: '.$CFG->version;
echo 'Humand readable release: '.$CFG->release;
I want the query 'SET NAMES utf8' to execute before any other queries.
But, if I execute it in the beginning of my app, it forces Zend_Db to connect to the Database, even if I'm not running any other queries. It isn't cool: My app processes lots of requests without any queries, only using cache.
How to ask Zend_Db to run 'SET NAMES utf8' right after connection?
Sure, simply pass the 'charset' option in with the adapter params. You can do this via Zend_Config or in code:
$params = array(
'host' => '127.0.0.1',
'username' => 'webuser',
'password' => 'xxxxxxxx',
'dbname' => 'test',
'charset' => 'utf8'
);
$db = Zend_Db::factory('Pdo_Mysql', $params);
Reference: http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.connecting.parameters
check this link for config option , its more easier
How to make PDO run SET NAMES utf8 each time I connect, In ZendFramework.
How can I find the standard site_perl (non-arch specific) location? Is it safe to just loop over #INC and find the path ending with "site_perl", or is there a standard way to do this?
The reason for trying to find this, is I have a very large project built up from hundreds of individual modules, all with their own Makefile.PL files (pretty much every .pm file has been built as its own CPAN style module). Along with this, each module may have artifacts (templates, .cgi's, etc), in various locations, all which need to be deployed to various locations, nothing is standard. This is the first step in trying to get this under control, basically having a single Makefile which can find and deploy everything, the next step will be getting it in sensible layout in version control.
I've spent time trying to do this with standard installation tools, but have had no luck.
C:\Temp> perl -MConfig -e "print qq{$_ => $Config{$_}\n} for grep { /site/ } keys %Config"
d_sitearch => define
installsitearch => C:\opt\perl\site\lib
installsitebin => C:\opt\perl\site\bin
installsitehtml1dir =>
installsitehtml3dir =>
installsitelib => C:\opt\perl\site\lib
installsiteman1dir =>
installsiteman3dir =>
installsitescript => C:\opt\perl\site\bin
sitearch => C:\opt\perl\site\lib
sitearchexp => C:\opt\perl\site\lib
sitebin => C:\opt\perl\site\bin
sitebinexp => C:\opt\perl\site\bin
sitehtml1dir =>
sitehtml1direxp =>
sitehtml3dir =>
sitehtml3direxp =>
sitelib => C:\opt\perl\site\lib
sitelib_stem =>
sitelibexp => C:\opt\perl\site\lib
siteman1dir =>
siteman1direxp =>
siteman3dir =>
siteman3direxp =>
siteprefix => C:\opt\perl\site
siteprefixexp => C:\opt\perl\site
sitescript =>
sitescriptexp =>
usesitecustomize => define
Or, as #ysth points out in comments, you can use:
C:\Temp> perl -V:.*site.*
on Windows and
$ perl '-V:.*site.*'
in *nix shells.
Is there a reason not to use one of the module installers (ExtUtils::MakeMaker, Module::Build, Module::Install)?
But if you must, the directory is available (after loading Config) as $Config::Config{'installsitelib'}. Note that some platforms may configure perl such that this directory doesn't literally appear in #INC, instead having some other directory that's symlinked to the installsitelib directory.
Just run perl -V. It will print the default #INC at the end.
It is not safe to loop over #INC as it can be modified by code or the environment, and, therefore, may contain multiple directories that end in site_perl.
If you are trying to determine where a given module is installed use %INC.